Skip to content

Conversation

@msullivan
Copy link
Member

Currently only the overloaded scalar cases seem to work for functions
taking typevars. Handle them by having _typing_dispatch look at
typevar bounds.

Comment on lines +65 to +70
atype = args[0]
if isinstance(atype, TypeVar):
atype = atype.__bound__
ns = _namespace.module_ns_of(fn)
atype = _typing_eval.resolve_type(atype, globals=ns)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elprans I don't think I understand the runtype type representations to know whether this is sufficient; could we be hitting TypeVars in other cases?

Why do we have to do this special mro stuff?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially we might have nested typevars in functions of collections, e.g list[T], but I think that's currently broken, so doesn't need to be in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to do this special mro stuff?

That is for ExprAlias and friends I think.

Currently only the overloaded scalar cases seem to work for functions
taking typevars. Handle them by having _typing_dispatch look at
typevar bounds.

Fixes #897.
Fixes #936.
@msullivan msullivan merged commit 531ae30 into master Sep 30, 2025
43 checks passed
@msullivan msullivan deleted the fix-897 branch September 30, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants