Skip to content

Commit

Permalink
Merge pull request #225 from robin-nitrokey/mypy-0.900
Browse files Browse the repository at this point in the history
Migrate mypy configuration into pyproject.toml
  • Loading branch information
szszszsz authored May 20, 2022
2 parents b54973d + c474803 commit 4cf60b3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ VENV=venv
BLACK_FLAGS=-t py35 --extend-exclude pynitrokey/nethsm/client
FLAKE8_FLAGS=--extend-exclude pynitrokey/nethsm/client
ISORT_FLAGS=--py 35 --extend-skip pynitrokey/nethsm/client
MYPY_FLAGS=--config-file mypy.ini

# whitelist of directories for flake8
FLAKE8_DIRS=pynitrokey/nethsm pynitrokey/cli/nk3 pynitrokey/nk3
Expand All @@ -30,7 +29,7 @@ isort:

lint:
$(VENV)/bin/python3 -m flake8 $(FLAKE8_FLAGS) $(FLAKE8_DIRS)
MYPYPATH=pynitrokey/stubs $(VENV)/bin/python3 -m mypy $(MYPY_FLAGS) $(PACKAGE_NAME)
$(VENV)/bin/python3 -m mypy $(PACKAGE_NAME)

semi-clean:
rm -rf **/__pycache__
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We use `flake8`_ for style checks, `black`_ for code formatting, `isort`_ for im
.. _isort: https://github.com/PyCQA/isort
.. _mypy: https://github.com/python/mypy

mypy is configured to only check annotated code. If you add new code, please consider adding type annotations and enabling strict checks for your modules in ``mypy.ini``.
mypy is configured to only check annotated code. If you add new code, please consider adding type annotations and enabling strict checks for your modules in ``pyproject.toml``.

Please make sure that all checks pass for your code before opening a PR.

Expand Down
13 changes: 0 additions & 13 deletions mypy.ini

This file was deleted.

37 changes: 36 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dev = [
"flit >=3.2,<4",
"ipython",
"isort",
"mypy",
"mypy >= 0.900",
"types-requests",
]

Expand All @@ -57,3 +57,38 @@ nitropy = "pynitrokey.cli:main"

[tool.isort]
profile = "black"

[tool.mypy]
mypy_path = "pynitrokey/stubs"

# enable strict checks for new code
[[tool.mypy.overrides]]
module = [
"pynitrokey.cli.nk3.*",
"pynitrokey.nk3.*",
"pynitrokey.updates.*",
]
disallow_untyped_defs = true

# pynitrokey.nethsm.client is auto-generated
[[tool.mypy.overrides]]
module = "pynitrokey.nethsm.client.*"
ignore_errors = true

# libraries without annotations
[[tool.mypy.overrides]]
module = [
"cbor.*",
"cffi.*",
"click.*",
"ecdsa.*",
"intelhex.*",
"nacl.*",
"nkdfu.*",
"ruamel.*",
"serial.*",
"urllib3.*",
"usb.*",
"usb1.*",
]
ignore_missing_imports = true

0 comments on commit 4cf60b3

Please sign in to comment.