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
test.py:6: error: Revealed type is 'Union[builtins.str, builtins.int]'
test.py:7: error: Argument 1 to "lower" of "str" has incompatible type "Union[str, int]"; expected "str"
This works if the conditional is extended with isinstance(a, str).
As noted in the referenced issue, attention must be paid to __eq__ being overrideable, meaning it cannot safely be inferred that the type of X in X == Type() is Type (or a subclass thereof) without looking into __eq__ overrides in both classes. I do not know how widely this is used for any types or for str, but I can say that I have never seen this myself. It seems that some types are more likely to compare equal to custom classes than others (e.g. None vs list), however.
The text was updated successfully, but these errors were encountered:
Basically the same issue as #1825 but more general.
This works if the conditional is extended with
isinstance(a, str)
.As noted in the referenced issue, attention must be paid to
__eq__
being overrideable, meaning it cannot safely be inferred that the type ofX
inX == Type()
isType
(or a subclass thereof) without looking into__eq__
overrides in both classes. I do not know how widely this is used for any types or for str, but I can say that I have never seen this myself. It seems that some types are more likely to compare equal to custom classes than others (e.g.None
vslist
), however.The text was updated successfully, but these errors were encountered: