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
This crash likely arises due to a combination of decorators and generators. I created a minimal example below (it is derived from a more complex project and might make no sense in the shown context but the crash still occurs).
Traceback
Traceback (most recent call last):
File "mypy/checker.py", line 576, in accept
File "mypy/nodes.py", line 923, in accept
File "mypy/checker.py", line 5136, in visit_decorator
File "mypy/checker.py", line 5163, in visit_decorator_inner
File "mypy/checkexpr.py", line 1572, in check_call
File "mypy/checkexpr.py", line 1757, in check_callable_call
File "mypy/checkexpr.py", line 2100, in infer_function_type_arguments
File "mypy/checkexpr.py", line 2235, in infer_function_type_arguments_pass2
File "mypy/infer.py", line 57, in infer_function_type_arguments
File "mypy/constraints.py", line 251, in infer_constraints_for_callable
File "mypy/constraints.py", line 319, in infer_constraints
File "mypy/constraints.py", line 427, in _infer_constraints
File "mypy/types.py", line 2009, in accept
File "mypy/constraints.py", line 1182, in visit_callable_type
File "mypy/constraints.py", line 1349, in infer_against_any
I have a fix ready, will make a PR soon. Couple comments in the meantime:
Your decorators are missing return types, in mypy a missing function annotation (whether return or argument) always means Any. This means those decorators "destroy" the types of functions they decorate (we have options to warn about such cases, like --disallow-untyped-decorators, or even stricter one --disallow-any-decorated).
Although not technically an error, usually a union of two plain type variables is a "bad" type, see if you can refactor your real code to avoid this.
Fixes#18780
Fix is trivial: handle a missing case. Note I re-use
`flatten_nested_tuples()` out of laziness. In theory, there should be at
most one level of nesting at this point, after which we should put an
assert (and IIRC we do something like this in other places). But I think
it is not worth the effort here, as this is a quite niche edge case
anyway.
Thanks for the fast fix!
I will have a look to incorporate --disallow-untyped-decorators. I think for the my real code this should already be properly implemented.
Crash Report
This crash likely arises due to a combination of decorators and generators. I created a minimal example below (it is derived from a more complex project and might make no sense in the shown context but the crash still occurs).
Traceback
To Reproduce
If I remove the
dec1
the crash disappears.My Environment
mypy.ini
(and other config files): noneI reproduced this with mypy version 1.14
The text was updated successfully, but these errors were encountered: