experiment: mark Mapping and Sequence with disjoint_base#16056
Closed
randolf-scholz wants to merge 1 commit into
Closed
experiment: mark Mapping and Sequence with disjoint_base#16056randolf-scholz wants to merge 1 commit into
randolf-scholz wants to merge 1 commit into
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/schedules.py:584: error: Subclass of "Sequence[int]" and "float" cannot exist: have distinct disjoint bases [unreachable]
+ tanjun/schedules.py:585: error: Statement is unreachable [unreachable]
mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/utils/templates.py:47: error: Subclass of "ExtraScriptValue" and "str" cannot exist: have distinct disjoint bases [unreachable]
xarray (https://github.com/pydata/xarray)
+ xarray/core/dataset.py:202: error: Class "Dataset" has incompatible disjoint bases [misc]
|
Member
Overall I think it's worth looking for ways to keep type checkers from considering multiple inheritance scenarios that are very unlikely in practice. Incorrect typeshed stubs might not be the best way though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The intersection type
Mapping[str, T] & Sequence[T]is non-empty, which can be really annoying for parsing nested data structures. This is an experiment to see what happens when we mark them with@disjoint_base.