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
{{ message }}
Repository navigation
Recent change to MROs of built-in types caused Python 2/3 inconsistency #2655
#2602 caused this to behave differently in mypy Python 2 and 3 modes:
reveal_type(['a', {'b'}])
In Python 2 mode it shows this:
Revealed type is 'builtins.list[typing.Sized*]'
In Python 3 mode it shows this:
Revealed type is 'builtins.list[typing.Collection*[builtins.str]]'
Before the PR Python 2 behavior was closer to Python 3:
Revealed type is 'builtins.list[typing.Iterable*[builtins.str]]'
This change causes regressions for mypy users, since the old type was more precise. More generally, any change in the MROs of built-in types has a significant chance of generating regressions and should be tested carefully.
Not sure what's the best way to move forward. I'd prefer getting Python 2 and Python 3 to be more similar if possible. Maybe we don't need to include Sized explicitly in the MRO since it's a protocol? Again, this could have unforeseen results.
I'm generally in favor of not including protocols in base classes, although in this case it makes some sense, since Sequence is part of the basic type hierarchy. For now I suggest to revert this change until mypy 0.650 is released and discuss this afterwards (and live with the results of that discussion).
Activity
srittau commentedon Nov 30, 2018
I'm generally in favor of not including protocols in base classes, although in this case it makes some sense, since
Sequenceis part of the basic type hierarchy. For now I suggest to revert this change until mypy 0.650 is released and discuss this afterwards (and live with the results of that discussion).Revert "Move Sized earlier in the bases of Sequence (python#2602)"
Revert "Move Sized earlier in the bases of Sequence (#2602)" (#2657)
Sync typeshed
Sync typeshed (#5979)
Stop inheriting Sized in collection ABCs
gvanrossum commentedon Nov 30, 2018
Reopening because I want a different fix (see #2658).
Stop inheriting Sized in collection ABCs (#2658)
Revert "Move Sized earlier in the bases of Sequence (python#2602)" (p…
Stop inheriting Sized in collection ABCs (python#2658)