Reject type variable whose upper bound is Self - #21967
Conversation
| fullname = self.qualified_name(type_param.name) | ||
| if type_param.upper_bound: | ||
| upper_bound = self.anal_type(type_param.upper_bound, allow_placeholder=True) | ||
| # TODO: we should validate the upper bound is valid for a given kind. |
There was a problem hiding this comment.
I’m not entirely sure if this is the kind of validity that this comment is referring to.
|
I filed #21961 for this issue with the narrower The check covers more than class D[U]:
def g[T: U](self, x: T) -> None: ...
class F:
def nested[T: list[Self]](self, x: T) -> None: ...The first is the plain "bound parametrized by a type variable" case the spec On fallout: with the check applied to Minor: |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #21960
First attempt by an ai agent, See: #21961