-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Delete sametypes.py #13311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete sametypes.py #13311
Conversation
@hauntsaninja @JelleZijlstra could one of you (or both) please take a look at this one as well? |
This comment has been minimized.
This comment has been minimized.
OK, so |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@JukkaL After some thinking, I decided to use I went again through all call sites (there is just a dozen or so), and I think the semantics introduced by this PR makes sense there. |
After working a bit on cleaning |
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
- python/pyspark/sql/pandas/types.py:351: error: Redundant cast to PandasSeriesLike? [redundant-cast]
- python/pyspark/sql/pandas/types.py:412: error: Redundant cast to PandasSeriesLike? [redundant-cast]
- python/pyspark/sql/pandas/types.py:422: error: Redundant cast to PandasSeriesLike? [redundant-cast]
cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/main.py: note: In function "main":
- cwltool/main.py:1128:26: error: Redundant cast to "Union[Any, Any]" [redundant-cast]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/package.py:227: error: Unsupported left operand type for & (Self?) [operator]
core (https://github.com/home-assistant/core)
- homeassistant/components/simplisafe/__init__.py:255: error: Redundant cast to "Union[Any, Any]" [redundant-cast]
|
Fixes #7924
So this is not 100% refactor, I make several semantic changes. As discussed in the issue, current implementation is not very principled, so I replace old complex logic with two options:
is_same_types()
is now located insubtypes.py
and is doing two-way proper subtyping check.==
can be used when we are checking for representation equality (used rarely, mostly for internal things)Btw this uncovered two actual bugs, one of which I fix here (two-line change), and leave a TODO for the second. Let's keep fingers crossed for
mypy_primer
.cc @JukkaL