Skip to content

Revert "Infer correct types with overloads of Type[Guard | Is] #19161

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 1 commit into from
May 29, 2025

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 28, 2025

This reverts commit 43ea203 (#17678).

The commit caused a regression (#19139). If we can't fix the regression soon enough, reverting the original change temporarily will at least unblock the mypy public release. The reverted PR can be merged again once the regression is fixed.

)"

This reverts commit 43ea203.

The commit caused a regression (#19139). If we can't fix the
regression soon enough, reverting the original change temporarily will
at least unblock the mypy public release. The reverted PR can be
merged again once the regression is fixed.
@JukkaL
Copy link
Collaborator Author

JukkaL commented May 28, 2025

cc @sobolevn

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/file_api/reply.py:106: error: "DataclassInstance" not callable  [operator]
- src/scikit_build_core/file_api/reply.py:106: note: Error code "operator" not covered by "type: ignore" comment

discord.py (https://github.com/Rapptz/discord.py)
- discord/ui/select.py:1075: error: Item "function" of "Callable[[V, Interaction[Any], BaseSelectT], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]" has no attribute "__discord_ui_model_type__"  [union-attr]
+ discord/ui/select.py:1075: error: "Callable[[V, Interaction[Any], BaseSelectT], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_type__"  [attr-defined]
- discord/ui/select.py:1076: error: Item "function" of "Callable[[V, Interaction[Any], BaseSelectT], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [union-attr]
+ discord/ui/select.py:1076: error: "Callable[[V, Interaction[Any], BaseSelectT], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [attr-defined]
- discord/ui/select.py:1085: error: Item "function" of "Callable[[V, Interaction[Any], BaseSelectT], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [union-attr]
+ discord/ui/select.py:1085: error: "Callable[[V, Interaction[Any], BaseSelectT], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [attr-defined]
- discord/ui/select.py:1087: error: Item "function" of "Callable[[V, Interaction[Any], BaseSelectT], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [union-attr]
+ discord/ui/select.py:1087: error: "Callable[[V, Interaction[Any], BaseSelectT], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [attr-defined]
- discord/ui/select.py:1103: error: Item "function" of "Callable[[V, Interaction[Any], BaseSelectT], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [union-attr]
+ discord/ui/select.py:1103: error: "Callable[[V, Interaction[Any], BaseSelectT], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__"  [attr-defined]
- discord/ext/tasks/__init__.py:631: error: Incompatible return value type (got "Callable[[Any, BaseException], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", expected "ET")  [return-value]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/ext/commands/commands.py:331: error: Incompatible types in assignment (expression has type "InvokeT", variable has type "None")  [assignment]
+ steam/ext/commands/commands.py:339: error: Incompatible types in assignment (expression has type "InvokeT", variable has type "None")  [assignment]
- steam/ext/commands/commands.py:324: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]", expected "ErrT")  [return-value]
- steam/ext/commands/commands.py:331: error: Incompatible types in assignment (expression has type "Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]", variable has type "None")  [assignment]
- steam/ext/commands/commands.py:332: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]", expected "InvokeT")  [return-value]
- steam/ext/commands/commands.py:339: error: Incompatible types in assignment (expression has type "Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]", variable has type "None")  [assignment]
- steam/ext/commands/commands.py:340: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]", expected "InvokeT")  [return-value]
- steam/ext/commands/help.py:138: note:          Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]]
+ steam/ext/commands/help.py:138: note:          ErrT
- steam/ext/commands/cog.py:180: error: Incompatible return value type (got "Callable[[Any | None, VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, None]] | Callable[[Any | None, VarArg(Any), KwArg(Any)], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", expected "F")  [return-value]
+ steam/ext/commands/bot.py:467: error: Incompatible types in assignment (expression has type "BotInvokeT", variable has type "None")  [assignment]
+ steam/ext/commands/bot.py:475: error: Incompatible types in assignment (expression has type "BotInvokeT", variable has type "None")  [assignment]
- steam/ext/commands/bot.py:467: error: Incompatible types in assignment (expression has type "Callable[[Context[Any]], CoroutineType[Any, Any, None]] | Callable[[Context[Any]], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", variable has type "None")  [assignment]
- steam/ext/commands/bot.py:468: error: Incompatible return value type (got "Callable[[Context[Any]], CoroutineType[Any, Any, None]] | Callable[[Context[Any]], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", expected "BotInvokeT")  [return-value]
- steam/ext/commands/bot.py:475: error: Incompatible types in assignment (expression has type "Callable[[Context[Any]], CoroutineType[Any, Any, None]] | Callable[[Context[Any]], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", variable has type "None")  [assignment]
- steam/ext/commands/bot.py:476: error: Incompatible return value type (got "Callable[[Context[Any]], CoroutineType[Any, Any, None]] | Callable[[Context[Any]], CoroutineType[Any, Any, Any]] | Callable[..., CoroutineType[Any, Any, Any]]", expected "BotInvokeT")  [return-value]

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@JukkaL JukkaL merged commit c197d98 into master May 29, 2025
18 checks passed
@JukkaL JukkaL deleted the revert-typeguard-overload branch May 29, 2025 09:40
JukkaL added a commit that referenced this pull request May 29, 2025
)

This reverts commit 43ea203 (#17678).

The commit caused a regression (#19139). If we can't fix the regression
soon enough, reverting the original change temporarily will at least
unblock the mypy public release. The reverted PR can be merged again
once the regression is fixed.
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request May 31, 2025
…hon#19161)

This reverts commit 43ea203 (python#17678).

The commit caused a regression (python#19139). If we can't fix the regression
soon enough, reverting the original change temporarily will at least
unblock the mypy public release. The reverted PR can be merged again
once the regression is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants