-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Narrow type variable bounds in binder #19183
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
Merged
Merged
Conversation
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This was referenced May 31, 2025
OK, the |
hauntsaninja
approved these changes
Jun 1, 2025
Hooray! |
sterliakov
approved these changes
Jun 1, 2025
Diff from mypy_primer, showing the effect of this PR on open source code: PyGithub (https://github.com/PyGithub/PyGithub)
+ github/MainClass.py:988: error: Unused "type: ignore" comment [unused-ignore]
antidote (https://github.com/Finistere/antidote): 1.47x slower (65.5s -> 96.3s in single noisy sample)
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/states.py:369: error: Argument 1 to "StateGroup" has incompatible type "Collection[Union[State[Any], Any]]"; expected "list[State[Any]]" [arg-type]
+ src/prefect/states.py:369: error: Argument 1 to "StateGroup" has incompatible type "Collection[Never]"; expected "list[State[Any]]" [arg-type]
+ src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[True] = ..., retry_result_failure: bool = ...) -> Any
+ src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[False] = ..., retry_result_failure: bool = ...) -> Union[Any, Exception]
+ src/prefect/futures.py:222: note: def result(self, raise_on_failure: bool = ..., retry_result_failure: bool = ...) -> Union[Any, Exception]
- src/prefect/task_engine.py:467: error: Item "type" of "Union[ResultRecord[Any], type[NotSet]]" has no attribute "result" [union-attr]
+ src/prefect/task_engine.py:467: error: Item "type" of "Union[R, type[NotSet]]" has no attribute "result" [union-attr]
- src/prefect/task_engine.py:1022: error: Item "type" of "Union[ResultRecord[Any], type[NotSet]]" has no attribute "result" [union-attr]
+ src/prefect/task_engine.py:1022: error: Item "type" of "Union[R, type[NotSet]]" has no attribute "result" [union-attr]
- src/prefect/flow_runs.py:292: error: Item "type" of "Union[type[AutomaticRunInput[Never]], type[T]]" has no attribute "load" [union-attr]
+ src/prefect/flow_runs.py:292: error: "type[T]" has no attribute "load" [attr-defined]
- src/prefect/flow_runs.py:307: error: Item "type" of "Union[type[AutomaticRunInput[Never]], type[T]]" has no attribute "save" [union-attr]
+ src/prefect/flow_runs.py:307: error: "type[T]" has no attribute "save" [attr-defined]
- src/prefect/flow_runs.py:319: error: Item "type" of "Union[type[AutomaticRunInput[Never]], type[T]]" has no attribute "load" [union-attr]
+ src/prefect/flow_runs.py:319: error: "type[T]" has no attribute "load" [attr-defined]
- src/prefect/flow_runs.py:446: error: Item "type" of "Union[type[AutomaticRunInput[Never]], type[T]]" has no attribute "load" [union-attr]
+ src/prefect/flow_runs.py:446: error: "type[T]" has no attribute "load" [attr-defined]
- src/prefect/flow_runs.py:456: error: Item "type" of "Union[type[AutomaticRunInput[Never]], type[T]]" has no attribute "save" [union-attr]
+ src/prefect/flow_runs.py:456: error: "type[T]" has no attribute "save" [attr-defined]
kopf (https://github.com/nolar/kopf)
+ kopf/_cogs/structs/dicts.py:243: error: Unused "type: ignore" comment [unused-ignore]
+ kopf/_core/intents/handlers.py:36: error: Redundant cast to "execution.CauseT" [redundant-cast]
python-chess (https://github.com/niklasf/python-chess)
- chess/pgn.py:1315: error: Returning Any from function declared to return "HeadersT" [no-any-return]
kornia (https://github.com/kornia/kornia)
+ kornia/utils/helpers.py:387: error: Unused "type: ignore" comment [unused-ignore]
mypy (https://github.com/python/mypy)
+ mypy/expandtype.py:125: error: Redundant cast to "F" [redundant-cast]
+ mypy/expandtype.py:125: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-redundant-cast for more info
+ mypy/typeops.py:421: error: Redundant cast to "F" [redundant-cast]
+ mypy/typeops.py:430: error: Redundant cast to "F" [redundant-cast]
+ mypy/typeops.py:469: error: Incompatible types in assignment (expression has type "CallableType", variable has type "F") [assignment]
+ mypy/typeops.py:484: error: Redundant cast to "F" [redundant-cast]
+ mypy/checkmember.py:1489: error: Redundant cast to "F" [redundant-cast]
+ mypy/checkmember.py:1492: error: Redundant cast to "F" [redundant-cast]
+ mypy/checkmember.py:1502: error: Redundant cast to "F" [redundant-cast]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/third_party/beartype.py:128: error: Incompatible types in assignment (expression has type "_T", variable has type "type[Any]") [assignment]
+ src/hydra_zen/third_party/beartype.py:128: error: Incompatible types in assignment (expression has type "_T", variable has type "_T") [assignment]
+ src/hydra_zen/third_party/beartype.py:130: error: Redundant cast to "_T" [redundant-cast]
+ src/hydra_zen/third_party/pydantic.py:111: error: Redundant cast to "_T" [redundant-cast]
+ src/hydra_zen/third_party/pydantic.py:115: error: Redundant cast to "_T" [redundant-cast]
- src/hydra_zen/third_party/pydantic.py:123: error: Argument 1 has incompatible type "_T | type[object]"; expected "_T" [arg-type]
pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/fixtures.py:1132: error: Returning Any from function declared to return "FixtureValue" [no-any-return]
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/__init__.py:67: error: Unused "type: ignore" comment [unused-ignore]
+ tests/__init__.py:85: error: Unused "type: ignore" comment [unused-ignore]
beartype (https://github.com/beartype/beartype)
+ beartype/_decor/_type/decortype.py:133: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_type/decortype.py:295: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_nontype/decornontype.py:294: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_nontype/decornontype.py:301: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_nontype/decornontype.py:380: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_nontype/decornontype.py:395: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/_nontype/decornontype.py:567: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_decor/decorcore.py:133: error: Unused "type: ignore" comment [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/structure/alignment.py: note: In function "_broadcast_helper":
+ xarray/structure/alignment.py:1140: error: Redundant cast to "T_Alignable" [redundant-cast]
+ xarray/structure/alignment.py:1142: error: Redundant cast to "T_Alignable" [redundant-cast]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/ext/commands/commands.py:284: error: Argument 1 to "append" of "list" has incompatible type "Command[Any, Any, Any]"; expected "Self" [arg-type]
- steam/ext/commands/cog.py:182: error: Argument 1 to "decorator" has incompatible type "Callable[[Any | None, VarArg(Any), KwArg(Any)], Coroutine[Any, Any, None]]"; expected "F" [arg-type]
- steam/ext/commands/bot.py:415: error: Argument 1 to "decorator" has incompatible type "Callable[..., Coroutine[Any, Any, Any]]"; expected "F" [arg-type]
|
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.
Fixes #5720
Fixes #8556
Fixes #9778
Fixes #10003
Fixes #10817
Fixes #11163
Fixes #11664
Fixes #12882
Fixes #13426
Fixes #13462
Fixes #14941
Fixes #15151
Fixes #19166
This handles a (surprisingly) common edge case. The charges in
bind_self()
andbind_self_fast()
are tricky. I got a few "Redundant cast" errors there, which seemed good, but then I realized that attribute access etc. on a type variable go through slowPyObject
paths, so I am actually forcingCallableType
instead ofF(bound=CallableType)
there, since these are performance-critical functions.