any-type (ANN401)
Derived from the flake8-annotations linter.
What it does
Checks that function arguments are annotated with a more specific type than
Any
.
Why is this bad?
Any
is a special type indicating an unconstrained type. When an
expression is annotated with type Any
, type checkers will allow all
operations on it.
It's better to be explicit about the type of an expression, and to use
Any
as an "escape hatch" only when it is really needed.
Example
Use instead:
Known problems
Type aliases are unsupported and can lead to false positives. For example, the following will trigger this rule inadvertently: