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 potential solution would be to disallow all default values for generic attributes except None. This is however a low priority, since it is a false negative, and a rare corner case.
The text was updated successfully, but these errors were encountered:
We don’t need to go so far as disallowing all defaults other than None. Any default value is fine as long as the default value has a type that can be written without T. For example:
x: Sequence[T] = [] is fine because [] has type Sequence[Never], which can be written without T, but is convertible to Sequence[T] by covariance. That is, a single [] may simultaneously have type Sequence[T] for all T.
x: List[T] = [] must be disallowed; no single [] may simultaneously have type List[T] for all T.
Currently mypy accepts this unsafe code:
A potential solution would be to disallow all default values for generic attributes except
None
. This is however a low priority, since it is a false negative, and a rare corner case.The text was updated successfully, but these errors were encountered: