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
Strange behavior 1: Function func1_1_copy is an exact copy of func1_1, yet mypy reports an error in func1_1_copy but not in func1_1.
Strange behavior 2: The protocol class MySequenceCopy is an exact copy of MySequence, so I would expect them to behave the same from a type checking perspective. func2_2 is a copy of func2_1 with MySequence replaced with MySequenceCopy, so I would expect the two to produce the same type checking results. Mypy emits no error for func1_2 but emits an error for func2_2.
Strange behavior 3: The protocol class _NestedSequence contains a commented-out __contains__ method. If this method is added back, I would expect there to be no change to the type checking results. Yet, when __contains__ is added here, all of the errors previously reported by mypy disappear. This includes the errors in the final line of the sample. I would not expect the addition of __contains__ to have any impact on the results.
I'm not sure if these three issues are related, but I suspect they are.
I'm using the latest published version of mypy (0.982).
The text was updated successfully, but these errors were encountered:
I ran into some strange behavior in mypy when investigating a bug reported against pyright.
Here is a sample that demonstrates the issue:
Strange behavior 1: Function
func1_1_copy
is an exact copy offunc1_1
, yet mypy reports an error infunc1_1_copy
but not infunc1_1
.Strange behavior 2: The protocol class
MySequenceCopy
is an exact copy ofMySequence
, so I would expect them to behave the same from a type checking perspective.func2_2
is a copy offunc2_1
withMySequence
replaced withMySequenceCopy
, so I would expect the two to produce the same type checking results. Mypy emits no error forfunc1_2
but emits an error forfunc2_2
.Strange behavior 3: The protocol class
_NestedSequence
contains a commented-out__contains__
method. If this method is added back, I would expect there to be no change to the type checking results. Yet, when__contains__
is added here, all of the errors previously reported by mypy disappear. This includes the errors in the final line of the sample. I would not expect the addition of__contains__
to have any impact on the results.I'm not sure if these three issues are related, but I suspect they are.
I'm using the latest published version of mypy (0.982).
The text was updated successfully, but these errors were encountered: