-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
If you run mypy on our plugins, there will be lots of errors:
» python -m mypy --config-file mypy_self_check.ini test-data/unit/plugins --disable-error-c
ode=no-untyped-def
test-data/unit/plugins/union_method.py:1: error: Module "mypy.plugin" does not explicitly
export attribute "CallableType" [attr-defined]
from mypy.plugin import (
^
test-data/unit/plugins/union_method.py:24: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(typ, Instance):
^~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/union_method.py:24: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/union_method.py:33: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(typ, Instance):
^~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/union_method.py:33: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/named_callable.py:15: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(ctx.default_return_type, CallableType):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/named_callable.py:15: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/named_callable.py:21: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(ctx.default_return_type, CallableType):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/named_callable.py:21: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/method_sig_hook.py:1: error: Module "mypy.plugin" does not
explicitly export attribute "CallableType" [attr-defined]
from mypy.plugin import CallableType, CheckerPluginInterface, MethodSigContext, P...
^
test-data/unit/plugins/method_sig_hook.py:17: error: Never apply isinstance() to
unexpanded types; use mypy.types.get_proper_type() first [misc]
if isinstance(typ, Instance):
^~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/method_sig_hook.py:17: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/method_in_decorator.py:15: error: Never apply isinstance() to
unexpanded types; use mypy.types.get_proper_type() first [misc]
if isinstance(ctx.default_return_type, CallableType):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/method_in_decorator.py:15: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/function_sig_hook.py:1: error: Module "mypy.plugin" does not
explicitly export attribute "CallableType" [attr-defined]
from mypy.plugin import CallableType, FunctionSigContext, Plugin
^
test-data/unit/plugins/fully_qualified_test_hook.py:1: error: Module "mypy.plugin" does
not explicitly export attribute "CallableType" [attr-defined]
from mypy.plugin import CallableType, MethodSigContext, Plugin
^
test-data/unit/plugins/dyn_class_from_method.py:19: error: "Expression" has no attribute
"fullname" [attr-defined]
queryset_type_fullname = ctx.call.args[0].fullname
^~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/dyn_class_from_method.py:20: error: Item "None" of
"Optional[SymbolTableNode]" has no attribute "node" [union-attr]
queryset_info = ctx.api.lookup_fully_qualified_or_none(
^
test-data/unit/plugins/dyn_class_from_method.py:20: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
test-data/unit/plugins/dyn_class_from_method.py:20: error: Incompatible types in
assignment (expression has type "Union[SymbolNode, None, Any]", variable has type
"TypeInfo") [assignment]
queryset_info = ctx.api.lookup_fully_qualified_or_none(
^
test-data/unit/plugins/dyn_class.py:37: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(node, Var) and isinstance(node.type, Instance):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/dyn_class.py:37: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/descriptor.py:18: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
if isinstance(ctx.arg_types[0][0], NoneType):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/descriptor.py:18: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/common_api_incremental.py:29: error: Incompatible types in
assignment (expression has type "bool", target has type "Dict[str, Any]") [assignment]
info.metadata["magic"] = True
^~~~
test-data/unit/plugins/class_callable.py:14: error: Never apply isinstance() to unexpanded
types; use mypy.types.get_proper_type() first [misc]
assert isinstance(ctx.default_return_type, Instance)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/class_callable.py:14: note: If you pass on the original type after the check, always use its unexpanded version
test-data/unit/plugins/arg_names.py:34: error: "Expression" has no attribute "value"
[attr-defined]
classname = ctx.args[ctx.callee_arg_names.index("classname")][0].value
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-data/unit/plugins/arg_names.py:39: error: "Expression" has no attribute "value"
[attr-defined]
classname = ctx.args[ctx.callee_arg_names.index("classname")][0].value
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 19 errors in 12 files (checked 30 source files)
I propose fixing them and running mypy on our own test plugins as a part of the CI.
It is fast, but can potentially catch some regressions / typing changes / etc.
I found this while working on my new mypy plugin and just saw an error.