Closed sedders123 closed 5 years ago
For reference, current mypy config:
[mypy]
warn_unused_ignores = True
strict_optional = True
disallow_any_generics = True
check_untyped_defs = True
ignore_missing_imports = True
I've had a look at the mypy docs and I think we may want a few more parameters than you suggest in order to strictly enforce typing.
disallow_any_unimported
- Disallows usage of types that come from unfollowed imports (anything imported from an unfollowed import is automatically given a type of Any
)disallow_any_expr
- Disallows all expressions in the module that have type Any
.disallow_any_decorated
- Disallows functions that have Any
in their signature after decorator transformation.disallow_any_explicit
- Disallows explicit Any
in type positions such as type annotations and generic type parameters.disallow_any_generics
- Disallows usage of generic types that do not specify explicit type parameters.disallow_subclassing_any
- Disallows subclassing a value of type Any
.disallow_untyped_calls
- Disallows calling functions without type annotations from functions with type annotations.disallow_untyped_defs
- Disallows defining functions without type annotations or with incomplete type annotations.disallow_incomplete_defs
- Disallows defining functions with incomplete type annotations.disallow_untyped_decorators
- Reports an error whenever a function with type annotations is decorated with a decorator without annotations.I agree that optionals should be explicit.
no_implicit_optional
- Changes the treatment of arguments with a default value of None
by not implicitly making their type Optional
.warn_return_any
- Shows a warning when returning a value with type Any
from a function declared with a non- Any
return type.I'm aware that some of this is outside the scope of this PR, but I decided to look through all of the mypy config options.
Now that the majority of the project has type hints, we should try to keep it that way. We can enforce this by changing our mypy settings to enforce code has type hints.
I propose we enable the following flags, though I'm open to discussion (these are the command line flags but they have equivalent
.cfg
options):Docs for the above flags can he found here