Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend strict mypy checks #443

Closed
robin-nitrokey opened this issue Sep 20, 2023 · 0 comments · Fixed by #444
Closed

Extend strict mypy checks #443

robin-nitrokey opened this issue Sep 20, 2023 · 0 comments · Fixed by #444

Comments

@robin-nitrokey
Copy link
Member

mypy has a strict mode that enables additional checks. Unfortunately, this mode can only be set globally, see python/mypy#11401. As we started with a code base without type annotations, setting it globally is not realistic at the moment. In the initial implementation, I just enabled disallow_untyped_defs for the new code to emulate the strict mode:

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

But strict mode actually includes many more settings that we should also enable. See this comment for an example configuration: python/mypy#11401 (comment)

robin-nitrokey added a commit to robin-nitrokey/pynitrokey that referenced this issue Sep 20, 2023
Strict mypy checks cannot be enabled on a per-module level, so we used
the disallow_untyped_defs option to replace them.  But actually there
are many more options that would be set in strict mode.  This patch adds
these options to the mypy configuration, fixes some missing or wrong
annotations and adds some ignores for more complex issues so that the
checks still pass.

Fixes: Nitrokey#443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant