Skip to content
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

[backport] [used before def] handle walrus declaration in match subject correctly #14672

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

ilinum
Copy link
Collaborator

@ilinum ilinum commented Feb 10, 2023

Backport of #14665.

python#14665)

The subject needs to be processed outside of match statement and not as
part of the first branch.

Fixes python#14659.
@github-actions
Copy link
Contributor

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

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/abc.py:2122: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
- https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
- Please report a bug at https://github.com/python/mypy/issues
- version: 1.0.0+dev.0665ce924290dad3f30010b3bb93310a71c8db81
- tanjun/abc.py:2122: : note: use --pdb to drop into pdb
- tanjun/abc.py:92: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:93: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:94: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:95: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:97: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:98: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:99: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:100: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:102: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:103: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:104: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
- tanjun/abc.py:105: error: Cannot resolve TypeVar upper bound (possible cyclic definition)  [misc]
+ tanjun/dependencies/reloaders.py:365: error: Argument 1 to "filter" has incompatible type "Callable[[Path], bool]"; expected "Callable[[Self], TypeGuard[bool]]"  [arg-type]
+ tanjun/dependencies/reloaders.py:365: error: Argument 1 to "map" has incompatible type "Callable[[Self, bool], Self]"; expected "Callable[[Path], Self]"  [arg-type]
+ tanjun/dependencies/reloaders.py:408: error: "ABC" has no attribute "type"  [attr-defined]
+ tanjun/dependencies/reloaders.py:408: error: "ABC" has no attribute "name"  [attr-defined]
+ tanjun/dependencies/reloaders.py:408: error: "ABC" has no attribute "build"  [attr-defined]
+ tanjun/dependencies/reloaders.py:512: error: Incompatible return value type (got "Tuple[Path, Union[Tuple[None, Set[<nothing>]], Tuple[str, Set[<nothing>]]]]", expected "Tuple[Path, Union[Tuple[str, Set[str]], Tuple[None, Set[Path]]]]")  [return-value]
+ tanjun/context/slash.py:995: error: List item 0 has incompatible type "_OtherT"; expected "_T"  [list-item]
+ tanjun/context/slash.py:1044: error: Signature of "command" incompatible with supertype "Context"  [override]
+ tanjun/context/message.py:130: error: Signature of "command" incompatible with supertype "Context"  [override]
+ tanjun/schedules.py:339: error: Argument 1 to "call_with_async_di" of "Client" has incompatible type "_CallbackSigT"; expected "Callable[..., Union[Coroutine[Any, Any, <nothing>], <nothing>]]"  [arg-type]
+ tanjun/schedules.py:365: error: Argument 1 to "call_with_async_di" of "Client" has incompatible type "Callable[..., Coroutine[Any, Any, None]]"; expected "Callable[..., Union[Coroutine[Any, Any, <nothing>], <nothing>]]"  [arg-type]
+ tanjun/schedules.py:388: error: Argument 1 to "call_with_async_di" of "Client" has incompatible type "Callable[..., Coroutine[Any, Any, None]]"; expected "Callable[..., Union[Coroutine[Any, Any, <nothing>], <nothing>]]"  [arg-type]
+ tanjun/schedules.py:1052: error: Argument 1 to "call_with_async_di" of "Client" has incompatible type "_CallbackSigT"; expected "Callable[..., Union[Coroutine[Any, Any, <nothing>], <nothing>]]"  [arg-type]
+ tanjun/parsing.py:1668: error: Right operand of "and" is never evaluated  [unreachable]
+ tanjun/parsing.py:1669: error: Statement is unreachable  [unreachable]
+ tanjun/parsing.py:1679: error: Statement is unreachable  [unreachable]
+ tanjun/context/menu.py:101: error: Signature of "command" incompatible with supertype "Context"  [override]
+ tanjun/context/menu.py:129: error: Incompatible return value type (got "Unique", expected "Union[InteractionMember, User, Message]")  [return-value]
+ tanjun/context/menu.py:141: error: Incompatible return value type (got "CommandType", expected "Literal[CommandType.USER, CommandType.MESSAGE]")  [return-value]
+ tanjun/context/menu.py:196: error: Argument "default" to "resolve_to_member" of "MenuContext" has incompatible type "None"; expected "User"  [arg-type]
+ tanjun/dependencies/limiters.py:782: error: Argument 1 to "add_pre_execution" of "Hooks" has incompatible type "CooldownPreExecution"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Optional[Coroutine[Any, Any, None]]]"  [arg-type]
+ tanjun/dependencies/limiters.py:782: note: "CooldownPreExecution.__call__" has type "Callable[[Context, Arg(AbstractCooldownManager, 'cooldowns'), DefaultNamedArg(Optional[AbstractLocaliser], 'localiser'), NamedArg(Optional[AbstractOwners], 'owner_check')], Coroutine[Any, Any, None]]"
+ tanjun/dependencies/limiters.py:1137: error: Argument 1 to "add_pre_execution" of "Hooks" has incompatible type "ConcurrencyPreExecution"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Optional[Coroutine[Any, Any, None]]]"  [arg-type]
+ tanjun/dependencies/limiters.py:1137: note: "ConcurrencyPreExecution.__call__" has type "Callable[[Context, Arg(AbstractConcurrencyLimiter, 'limiter'), DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], Coroutine[Any, Any, None]]"
+ tanjun/dependencies/limiters.py:1137: error: Argument 1 to "add_post_execution" of "Hooks" has incompatible type "ConcurrencyPostExecution"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Optional[Coroutine[Any, Any, None]]]"  [arg-type]
+ tanjun/dependencies/limiters.py:1137: note: "ConcurrencyPostExecution.__call__" has type "Callable[[Context, Arg(AbstractConcurrencyLimiter, 'limiter')], Coroutine[Any, Any, None]]"
+ tanjun/checks.py:620: error: Argument 2 to "_optional_kwargs" has incompatible type "DmCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:620: note: "DmCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], bool]"
+ tanjun/checks.py:686: error: Argument 2 to "_optional_kwargs" has incompatible type "GuildCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:686: note: "GuildCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], bool]"
+ tanjun/checks.py:748: error: Argument 2 to "_optional_kwargs" has incompatible type "NsfwCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:748: note: "NsfwCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], Coroutine[Any, Any, bool]]"
+ tanjun/checks.py:810: error: Argument 2 to "_optional_kwargs" has incompatible type "SfwCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:810: note: "SfwCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], Coroutine[Any, Any, bool]]"
+ tanjun/checks.py:872: error: Argument 2 to "_optional_kwargs" has incompatible type "OwnerCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:872: note: "OwnerCheck.__call__" has type "Callable[[Context, Arg(AbstractOwners, 'dependency'), DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], Coroutine[Any, Any, bool]]"
+ tanjun/checks.py:927: error: Argument 2 to "_add_to_command" has incompatible type "AuthorPermissionCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:927: note: "AuthorPermissionCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser')], Coroutine[Any, Any, bool]]"
+ tanjun/checks.py:983: error: Argument 2 to "_add_to_command" has incompatible type "OwnPermissionCheck"; expected "Callable[[_ContextT_contra, VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, bool], bool]]"  [arg-type]
+ tanjun/checks.py:983: note: "OwnPermissionCheck.__call__" has type "Callable[[Context, DefaultNamedArg(Optional[AbstractLocaliser], 'localiser'), DefaultNamedArg(OwnUser, 'my_user'), DefaultNamedArg(Optional[GuildBoundCache[Union[Snowflake, int], Member]], 'member_cache')], Coroutine[Any, Any, bool]]"
+ tanjun/checks.py:996: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1003: error: Overloaded function signature 3 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1003: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1010: error: Overloaded function signature 4 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1010: error: Overloaded function signature 4 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1010: error: Overloaded function signature 4 will never be matched: signature 3's parameter type(s) are the same or broader  [misc]
+ tanjun/checks.py:1087: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]

... (truncated 92 lines) ...

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 13, 2023

The mypy_primer output doesn't look related to this PR.

@JukkaL JukkaL merged commit 83db085 into python:release-1.0 Feb 13, 2023
@hauntsaninja
Copy link
Collaborator

The primer is related to an issue calculating the merge base (it assumed all PRs were targeting master).

I fixed, but the fix was not backported to the 1.0 branch

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.

3 participants