Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use polymorphic inference in unification #17348

Merged
merged 10 commits into from
Jun 10, 2024
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 9, 2024
commit 53288505ed694527bbb344d3b67e39fa7a77004d
7 changes: 5 additions & 2 deletions mypy/typeops.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def type_object_type_from_function(
signature = bind_self(
# Explicit instance self annotations have special handling in class_callable(),
# we don't need to bind any type variables in them if they are generic.
signature, original_type=default_self, is_classmethod=is_new, ignore_instances=True
signature,
original_type=default_self,
is_classmethod=is_new,
ignore_instances=True,
)
signature = cast(FunctionLike, map_type_from_supertype(signature, info, def_info))

Expand Down Expand Up @@ -323,7 +326,7 @@ class B(A): pass
# from such definition, since it is inherently indefinitely recursive.
allow_callable = func.name is None or not func.name.startswith("__call__ of")
if func.variables and supported_self_type(
self_param_type, allow_callable=allow_callable, allow_instances=not ignore_instances,
self_param_type, allow_callable=allow_callable, allow_instances=not ignore_instances
):
from mypy.infer import infer_type_arguments

Expand Down
Loading