Repository navigation
Harden mypy configuration - #1455
Conversation
sechkova
left a comment
There was a problem hiding this comment.
So the only way to find out what will be applied with the strict flag is to check mypy --strict on the current version ...
Anyway, I approve extending the list and see where this will lead us to.
Signed-off-by: Jussi Kukkonen <[email protected]>
unrecognized_fields is always initialized Signed-off-by: Jussi Kukkonen <[email protected]>
We're quite close to being able to enable only "strict = True" but not
quite there. In the mean time enable some useful individual settings.
disallow_untyped_defs:
report an error whenever code contains a function definition
without type annotations
warn_redundant_casts:
report an error whenever code uses an unnecessary cast
warn_unused_ignores:
report an error whenever code uses an unnecessary # type: ignore
comment
warn_unreachable:
report an error whenever code is determined to be unreachable or
redundant
Signed-off-by: Jussi Kukkonen <[email protected]>
exceptions.py is used from metadata.py: Annotating it is required if we want to enable "no_untyped_call" in mypy. The only change is UnsignedMetadataError: I would have removed argument "signable" altogether but figured this is not worth breaking API. So now "signable" is still not used for anything but it is now optional. Signed-off-by: Jussi Kukkonen <[email protected]>
report an error whenever a function with type annotations calls a function defined without annotations. Also include exceptions.py in mypy checks. Signed-off-by: Jussi Kukkonen <[email protected]>
|
rebased on develop, no changes |
joshuagl
left a comment
There was a problem hiding this comment.
Looks good to me, thanks!
We can almost enable "strict = True" already but
we should decide if we really want to do that (what strict means may change when mypy updates)
We should notice when the definition of strict changes thanks to CI, but could always pin mypy version and review updates for changes to the definition of strict?
| """Indicate metadata object with insufficient threshold of signatures.""" | ||
|
|
||
| def __init__(self, message, signable): | ||
| # signable is not used but kept in method signature for backwards compat |
There was a problem hiding this comment.
Do we want a FIXME or similar here? So that we are reminded to remove this unused variable before we tag 1.0?
We can almost enable "strict = True" already but
So fix a few issues and harden the mypy configuration where possible.
The one remaining possibly interesting option (that is currently included in "strict") is:
no_any_return: seems to require securesystemslib.formats annotations (or specifying some types in tuf code that calls securesystemslib)