-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Handle more ParamSpec literal form special cases #15256
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
Open
A5rocks
wants to merge
1
commit into
python:master
Choose a base branch
from
A5rocks:fix-ps-literal-special-case
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+48
−16
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 is more:tm: correct as shown by changes in test cases. I can't find any issues that are closed by this though. From what I remember, this was a followup fix for python#14903 in order to fix some incorrect mypy-primer output.
Diff from mypy_primer, showing the effect of this PR on open source code: sublime_debugger (https://github.com/daveleroy/sublime_debugger)
- modules/ui/input.py:11: error: Cannot infer type of lambda [misc]
- modules/ui/input.py:11: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[Any], Any]"; expected "Callable[[], Any]" [arg-type]
- modules/dap/session.py:105: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[Any], Any]"; expected "Callable[[VarArg(Iterable[ExceptionBreakpointsFilter]), KwArg(Iterable[ExceptionBreakpointsFilter])], Any]" [arg-type]
- modules/views/breakpoints.py:28: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[Any], None]"; expected "Callable[[VarArg(Iterable[ExceptionBreakpointsFilter]), KwArg(Iterable[ExceptionBreakpointsFilter])], Any]" [arg-type]
- modules/views/sources.py:21: error: Cannot determine type of "on_session_sources_updated" [has-type]
- modules/views/sources.py:22: error: Cannot determine type of "on_session_removed" [has-type]
- modules/views/modules.py:23: error: Cannot determine type of "on_session_modules_updated" [has-type]
- modules/views/modules.py:24: error: Cannot determine type of "on_session_removed" [has-type]
- modules/views/debugger.py:24: error: Cannot determine type of "on_session_active" [has-type]
- modules/views/debugger.py:25: error: Cannot determine type of "on_session_added" [has-type]
- modules/views/debugger.py:27: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[], Any]"; expected "Callable[[VarArg(None), KwArg(None)], Any]" [arg-type]
- modules/views/debugger.py:70: error: Cannot determine type of "on_session_removed" [has-type]
- modules/views/debugger.py:71: error: Cannot infer type of lambda [misc]
- modules/views/debugger.py:71: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[], Any]"; expected "Callable[[VarArg(None), KwArg(None)], Any]" [arg-type]
- modules/debugger_output_panel.py:21: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[], Any]"; expected "Callable[[VarArg(None), KwArg(None)], Any]" [arg-type]
- modules/views/variables.py:33: error: Cannot determine type of "on_session_variables_updated" [has-type]
- modules/views/variables.py:34: error: Cannot determine type of "on_session_removed" [has-type]
- modules/debugger.py:78: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:79: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:80: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:82: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:83: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:84: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:85: error: Incompatible types in assignment (expression has type "Event[Session]", base class "Debugger" defined the type as "Event[[Session]]") [assignment]
- modules/debugger.py:87: error: Type application has too many types (1 expected) [misc]
- modules/debugger.py:116: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[str], Future[None]]"; expected "Callable[[VarArg(str), KwArg(str)], Any]" [arg-type]
- modules/debugger.py:117: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[SourceLocation], Any]"; expected "Callable[[VarArg(SourceLocation), KwArg(SourceLocation)], Any]" [arg-type]
- modules/debugger.py:131: error: Argument 1 to "add" of "Event" has incompatible type "Callable[[], Any]"; expected "Callable[[VarArg(None), KwArg(None)], Any]" [arg-type]
- modules/debugger.py:145: error: Cannot determine type of "on_session_active" [has-type]
- modules/debugger.py:146: error: Cannot determine type of "on_session_added" [has-type]
- modules/debugger.py:147: error: Cannot determine type of "on_session_removed" [has-type]
- modules/debugger.py:347: error: Cannot determine type of "on_session_active" [has-type]
- modules/debugger.py:353: error: Cannot determine type of "on_session_modules_updated" [has-type]
- modules/debugger.py:356: error: Cannot determine type of "on_session_sources_updated" [has-type]
- modules/debugger.py:359: error: Cannot determine type of "on_session_variables_updated" [has-type]
- modules/debugger.py:362: error: Cannot determine type of "on_session_threads_updated" [has-type]
- modules/debugger.py:370: error: Cannot determine type of "on_session_added" [has-type]
- modules/debugger.py:371: error: Cannot determine type of "on_session_active" [has-type]
- modules/debugger.py:393: error: Cannot determine type of "on_session_active" [has-type]
- modules/debugger.py:395: error: Cannot determine type of "on_session_removed" [has-type]
- modules/debugger.py:472: error: Cannot determine type of "on_session_active" [has-type]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/ext/commands/converters.py:242: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "special_converters" [union-attr]
+ steam/ext/commands/converters.py:242: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "special_converters" [union-attr]
- steam/ext/commands/converters.py:242: error: Item "CallbackType[Any]" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "special_converters" [union-attr]
+ steam/ext/commands/converters.py:242: error: Item "CallbackType[[Any]]" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "special_converters" [union-attr]
- steam/ext/commands/converters.py:242: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__special_converters__" [union-attr]
+ steam/ext/commands/converters.py:242: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__special_converters__" [union-attr]
- steam/ext/commands/converters.py:245: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "special_converters" [union-attr]
+ steam/ext/commands/converters.py:245: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "special_converters" [union-attr]
- steam/ext/commands/converters.py:245: error: Item "CallbackType[Any]" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "special_converters" [union-attr]
+ steam/ext/commands/converters.py:245: error: Item "CallbackType[[Any]]" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "special_converters" [union-attr]
- steam/ext/commands/converters.py:247: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__special_converters__" [union-attr]
+ steam/ext/commands/converters.py:247: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__special_converters__" [union-attr]
+ steam/ext/commands/commands.py:732: error: Overloaded function implementation cannot satisfy signature 1 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:732: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:801: error: Overloaded function implementation cannot satisfy signature 1 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:801: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:907: error: Overloaded function implementation cannot satisfy signature 1 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:907: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:907: error: Overloaded function implementation cannot satisfy signature 3 due to inconsistencies in how they use type variables [misc]
- steam/ext/commands/commands.py:935: error: Argument 1 to "Command" has incompatible type "CallT"; expected "CallbackType[Any]" [arg-type]
+ steam/ext/commands/commands.py:935: error: Argument 1 to "Command" has incompatible type "CallT"; expected "CallbackType[[Any]]" [arg-type]
+ steam/ext/commands/commands.py:974: error: Overloaded function implementation cannot satisfy signature 1 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:974: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
- steam/ext/commands/commands.py:998: note: def [C <: Command[Any]] command(*, name: str | None = ..., cls: type[C] | None = ..., help: str | None = ..., brief: str | None = ..., usage: str | None = ..., description: str | None = ..., aliases: Iterable[str] | None = ..., checks: list[CheckReturnType] = ..., cooldown: list[Cooldown[Any]] = ..., special_converters: list[type[ConverterBase[Any]] | type[BasicConverter[Any]]] = ..., cog: Cog | None = ..., parent: Command[Any] | None = ..., enabled: bool = ..., hidden: bool = ..., case_insensitive: bool = ...) -> Callable[[Callable[P, Coroutine[Any, Any, Any]]], Command[P]]
+ steam/ext/commands/commands.py:998: note: def [C <: Command[[Any]]] command(*, name: str | None = ..., cls: type[C] | None = ..., help: str | None = ..., brief: str | None = ..., usage: str | None = ..., description: str | None = ..., aliases: Iterable[str] | None = ..., checks: list[CheckReturnType] = ..., cooldown: list[Cooldown[Any]] = ..., special_converters: list[type[ConverterBase[Any]] | type[BasicConverter[Any]]] = ..., cog: Cog | None = ..., parent: Command[Any] | None = ..., enabled: bool = ..., hidden: bool = ..., case_insensitive: bool = ...) -> Callable[[Callable[P, Coroutine[Any, Any, Any]]], Command[P]]
- steam/ext/commands/commands.py:1033: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__commands_checks__" [union-attr]
+ steam/ext/commands/commands.py:1033: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__commands_checks__" [union-attr]
- steam/ext/commands/commands.py:1035: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__commands_checks__" [union-attr]
+ steam/ext/commands/commands.py:1035: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__commands_checks__" [union-attr]
- steam/ext/commands/commands.py:1053: note: Consider using the upper bound "CommandDeco | Callable[..., Command[Any]] | CallbackType[Any]" instead
+ steam/ext/commands/commands.py:1053: note: Consider using the upper bound "CommandDeco | Callable[..., Command[[Any]]] | CallbackType[[Any]]" instead
- steam/ext/commands/commands.py:1084: note: Consider using the upper bound "CommandDeco | Callable[..., Command[Any]] | CallbackType[Any]" instead
+ steam/ext/commands/commands.py:1084: note: Consider using the upper bound "CommandDeco | Callable[..., Command[[Any]]] | CallbackType[[Any]]" instead
- steam/ext/commands/commands.py:1138: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__commands_cooldown__" [union-attr]
+ steam/ext/commands/commands.py:1138: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__commands_cooldown__" [union-attr]
- steam/ext/commands/commands.py:1139: error: Item "function" of the upper bound "Callable[..., Command[Any]] | CallbackType[Any]" of type variable "MC" has no attribute "__commands_cooldown__" [union-attr]
+ steam/ext/commands/commands.py:1139: error: Item "function" of the upper bound "Callable[..., Command[[Any]]] | CallbackType[[Any]]" of type variable "MC" has no attribute "__commands_cooldown__" [union-attr]
|
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.
This is more:tm: correct as shown by changes in test cases. I can't find any issues that are closed by this though. From what I remember, this was a followup fix for #14903 in order to fix some incorrect mypy-primer output.
This just removes a previous too-broad special case for
Z[Any]
whereZ
has a single paramspec parameter. Previously, this would be equivalent toZ[...]
. Now, it is equivalent toZ[[Any]]
, unless theAny
is from an error (invalid paramspec expressions will return anAny
withTypeOfAny.from_error
).EDIT: Oh yeah, this also addresses one case where this "nicer" syntax (I don't like it!) wasn't being interpreted correctly. See
testRuntimeSpecialParamspecLiteralSyntax
.