You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting an internal error when testing some code I'm trying to patch.
I've been unable to reproduce the problem with a trivial example, so I've pushed the changes to my GitHub profile.
To reproduce:
git clone [email protected]:andymwood/numpy-stubs.git
cd numpy-stubs
git checkout annotations # Currently on commit 33496555
pip install .
mypy --strict tests/pass/simple.py
which produces the following output:
tests/pass/simple.py:76: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.610
tests/pass/simple.py:76: : note: please use --show-traceback to print a traceback when reporting a bug
Here's the traceback:
Traceback (most recent call last):
File "/home/andrew/.conda/envs/numpy-stubs/bin/mypy", line 11, in<module>sys.exit(console_entry())
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/main.py", line 91, in main
res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/main.py", line 148, in type_check_only
fscache=fscache)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 185, in build
flush_errors, fscache)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 285, in _build
graph = dispatch(sources, manager)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 2398, in dispatch
process_graph(graph, manager)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 2691, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 2807, in process_stale_scc
graph[id].type_check_first_pass()
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/build.py", line 2029, in type_check_first_pass
self.type_checker().check_first_pass()
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checker.py", line 252, in check_first_pass
self.accept(d)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checker.py", line 351, in accept
stmt.accept(self)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/nodes.py", line 883, in accept
return visitor.visit_expression_stmt(self)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checker.py", line 2237, in visit_expression_stmt
self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 2407, in accept
typ = node.accept(self)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/nodes.py", line 1543, in accept
return visitor.visit_op_expr(self)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 1396, in visit_op_expr
allow_reverse=True)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 1523, in check_op
local_errors)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 1507, in check_op_local
callable_name=callable_name, object_type=object_type)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 577, in check_call
callee, args, arg_kinds, formal_to_actual, context)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/checkexpr.py", line 829, in infer_function_type_arguments
strict=self.chk.in_checked_function())
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/infer.py", line 31, in infer_function_type_arguments
callee_type, arg_types, arg_kinds, formal_to_actual)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 63, in infer_constraints_for_callable
SUPERTYPE_OF)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 170, in infer_constraints
fort_itemin template.items],
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 170, in<listcomp>fort_itemin template.items],
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 190, in infer_constraints_if_possible
return infer_constraints(template, actual, direction)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 174, in infer_constraints
return template.accept(ConstraintBuilderVisitor(actual, direction))
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/types.py", line 512, in accept
return visitor.visit_instance(self)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 351, in visit_instance
original_actual, template)
File "/home/andrew/.conda/envs/numpy-stubs/lib/python3.6/site-packages/mypy/constraints.py", line 393, in infer_constraints_from_protocol_members
assert inst is not None and temp is not None
AssertionError:
The text was updated successfully, but these errors were encountered:
For example in this particular case int doesn't implement SupportsComplex protocol, but it is considered a subtype of it because int is promoted to float, and then to complex. Then in the constraint inference code we assume that "if it is a subtype of a protocol, then it must have all members", which is not the case here.
A potential solution is to replace is_subtype with is_protocol_implementation in that protocol constraint inference branch.
I'm getting an internal error when testing some code I'm trying to patch.
I've been unable to reproduce the problem with a trivial example, so I've pushed the changes to my GitHub profile.
To reproduce:
which produces the following output:
tests/pass/simple.py:76: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.610 tests/pass/simple.py:76: : note: please use --show-traceback to print a traceback when reporting a bug
Here's the traceback:
The text was updated successfully, but these errors were encountered: