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

Fix crash on deferred value constrained TypeVar #14642

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,11 @@ def __hash__(self) -> int:
def __eq__(self, other: object) -> bool:
if not isinstance(other, TypeVarType):
return NotImplemented
return self.id == other.id and self.upper_bound == other.upper_bound
return (
self.id == other.id
and self.upper_bound == other.upper_bound
and self.values == other.values
)

def serialize(self) -> JsonDict:
assert not self.id.is_meta_var()
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-typevar-values.test
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,12 @@ class Indexable:

[builtins fixtures/tuple.pyi]
[builtins fixtures/classmethod.pyi]

[case testTypeVarWithValueDeferral]
from typing import TypeVar, Callable

T = TypeVar("T", "A", "B")
Func = Callable[[], T]

class A: ...
class B: ...