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
A crash happens while using _W wrapper below, which is a cut down version of functools._Wrapped.
Traceback
_broken.pyi:13: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.10.0
Traceback (most recent call last):
File "mypy/checker.py", line 589, in accept
File "mypy/nodes.py", line 586, in accept
File "mypy/checker.py", line 626, in visit_overloaded_func_def
File "mypy/checker.py", line 656, in _visit_overloaded_func_def
File "mypy/checker.py", line 767, in check_overlapping_overloads
File "mypy/checker.py", line 7813, in is_unsafe_overlapping_overload_signatures
File "mypy/subtypes.py", line 1521, in is_callable_compatible
File "mypy/subtypes.py", line 1862, in unify_generic_callable
File "mypy/constraints.py", line 311, in infer_constraints
File "mypy/constraints.py", line 407, in _infer_constraints
File "mypy/types.py", line 1444, in accept
File "mypy/constraints.py", line 802, in visit_instance
File "mypy/constraints.py", line 314, in infer_constraints
File "mypy/constraints.py", line 407, in _infer_constraints
File "mypy/types.py", line 1730, in accept
File "mypy/constraints.py", line 698, in visit_parameters
RuntimeError: Parameters cannot be constrained to
_broken.pyi:13: : note: use --pdb to drop into pdb
Moving towards #15907Fixes#17206
This PR enables polymorphic inference during unification. This will
allow us to handle even more tricky situations involving generic
higher-order functions (see a random example I added in tests).
Implementation is mostly straightforward, few notes:
* This uncovered another issue with unions in solver, unfortunately
current constraint inference algorithm can sometimes infer weird
constraints like `T <: Union[T, int]`, that later confuse the solver.
* This uncovered another possible type variable clash scenario that was
not handled properly. In overloaded generic function, each overload
should have a different namespace for type variables (currently they all
just get function name). I use `module.some_func#0` etc. for overloads
namespaces instead.
* Another thing with overloads is that the switch caused unsafe overlap
check to change: after some back and forth I am keeping it mostly the
same to avoid possible regressions (unfortunately this requires some
extra refreshing of type variables).
* This makes another `ParamSpec` crash to happen more often so I fix it
in this same PR.
* Finally this uncovered a bug in handling of overloaded `__init__()`
that I am fixing here as well.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Crash Report
A crash happens while using
_W
wrapper below, which is a cut down version offunctools._Wrapped
.Traceback
_broken.pyi
:Your Environment
mypy --show-traceback _broken.pyi
mypy.ini
(and other config files):mypy.ini
:The text was updated successfully, but these errors were encountered: