-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Update semantic analyzer for TypeVar defaults (PEP 696) #14873
Update semantic analyzer for TypeVar defaults (PEP 696) #14873
Conversation
This comment has been minimized.
This comment has been minimized.
10da8e7
to
ef479c6
Compare
This comment has been minimized.
This comment has been minimized.
ef479c6
to
eb7ba73
Compare
This comment has been minimized.
This comment has been minimized.
eb7ba73
to
f8e8f66
Compare
This comment has been minimized.
This comment has been minimized.
f8e8f66
to
e8bbe5c
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
a6ee900
to
575f772
Compare
This comment has been minimized.
This comment has been minimized.
575f772
to
0ea018e
Compare
This comment has been minimized.
This comment has been minimized.
Start implementing [PEP 696](https://peps.python.org/pep-0696/) TypeVar defaults. This PR * Adds a `default` parameter to `TypeVarLikeExpr` and `TypeVarLikeType`. * Updates most visitors to account for the new `default` parameter. * Update existing calls to add value for `default` => `AnyType(TypeOfAny.from_omitted_generics)`. A followup PR will update the semantic analyzer and add basic tests for `TypeVar`, `ParamSpec`, and `TypeVarTuple` calls with a `default` argument. -> #14873 Ref #14851
mypy/semanal.py
Outdated
param_value, | ||
) | ||
# Note: we do not return 'None' here -- we want to continue | ||
# using the AnyType as the upper bound. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# using the AnyType as the upper bound. | |
# using the AnyType. |
Or the default
mypy/semanal.py
Outdated
self.fail("Only the first argument to ParamSpec has defined semantics", s) | ||
n_values = call.arg_kinds[1:].count(ARG_POS) | ||
if n_values != 0: | ||
self.fail("Only the first positional argument to ParamSpec has defined semantics", s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually only takes one positional arg, the rest are keyword-only. So this error message seems imprecise; I think we can just say "Too many positional arguments to ParamSpec()"
mypy/semanal.py
Outdated
default = AnyType(TypeOfAny.from_error) | ||
else: | ||
self.fail( | ||
"The variance and bound arguments to TypeVarTuple do not have defined semantics yet", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in fact they do not exist at runtime
8622a58
to
d6e39c4
Compare
Rebased to fix the tests. The merge created two duplicate lines which caused the failures. Will take a look at the comments tomorrow. |
This comment has been minimized.
This comment has been minimized.
@cdce8p if you're happy with this PR now, feel free to take it out of draft and I'll review it. Maybe we should put this behind an |
This comment has been minimized.
This comment has been minimized.
The PR itself is fine. I'm just checking the primer output one more time to make sure but so far I looks as expected. The important thing to note is that these changes don't impact projects which haven't started using PEP 696 yet. For Will post a more detailed update regarding the primer output shortly. As for |
Primer analysis
- discord/_types.py:32: error: Unexpected argument to "TypeVar()": "default" [misc]
- discord/_types.py:32: error: Unexpected keyword argument "default" for "TypeVar" [call-arg]
- discord/state.py:1617: error: "ConnectionState" expects no type arguments, but 1 given [type-arg]
- discord/state.py:163: error: Free type variable expected in Generic[...] [misc]
- discord/state.py:166: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/state.py:166: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/state.py:166: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/state.py:166: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/app_commands/tree.py:128: error: ClientT? has no attribute "http" [attr-defined]
- discord/interactions.py:255: error: Incompatible return value type (got "ConnectionState | Guild | None", expected "Guild | None") [return-value]
+ discord/interactions.py:255: error: Incompatible return value type (got "ConnectionState[ClientT] | Guild | None", expected "Guild | None") [return-value]
+ steam/id.py:576: error: Need type annotation for "id" [var-annotated]
+ steam/app.py:94: error: Incompatible default for argument "name" (default has type "None", argument has type "NameT") [assignment] Overall the result looks as expected and should improve further once the |
Diff from mypy_primer, showing the effect of this PR on open source code: steam.py (https://github.com/Gobot1234/steam.py)
- steam/types/user.py:137: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/types/user.py:139: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/types/user.py:142: error: "ID" expects no type arguments, but 1 given [type-arg]
- steam/id.py:223: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/id.py:226: error: Free type variable expected in Generic[...] [misc]
- steam/id.py:294: error: Variable "steam.id.TypeT" is not valid as a type [valid-type]
- steam/id.py:294: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/id.py:331: error: Variable "steam.id.TypeT" is not valid as a type [valid-type]
- steam/id.py:331: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/id.py:333: error: Variable "steam.id.TypeT" is not valid as a type [valid-type]
- steam/id.py:333: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/id.py:546: error: "ID" expects no type arguments, but 1 given [type-arg]
- steam/id.py:567: error: "ID" expects no type arguments, but 1 given [type-arg]
- steam/id.py:581: error: The type "type[ID]" is not generic and not indexable [misc]
+ steam/id.py:576: error: Need type annotation for "id" [var-annotated]
+ steam/id.py:581: error: Parameter 1 of Literal[...] is invalid [valid-type]
+ steam/badge.py:123: error: Argument 1 to "inventory" of "PartialUser" has incompatible type "tuple[str, int, int]"; expected "App[Any]" [arg-type]
+ steam/badge.py:185: error: Argument 4 to "__init__" of "BaseOwnedBadge" has incompatible type "object"; expected "PartialApp[Any]" [arg-type]
+ steam/app.py:94: error: Incompatible default for argument "name" (default has type "None", argument has type "NameT") [assignment]
+ steam/app.py:94: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ steam/app.py:94: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
+ steam/app.py:116: error: Incompatible return value type (got "NameT | str", expected "str") [return-value]
+ steam/app.py:129: error: Argument "game_extra_info" to "CMsgClientGamesPlayedGamePlayed" has incompatible type "NameT"; expected "str" [arg-type]
+ steam/app.py:195: error: Need type annotation for "app" [var-annotated]
+ steam/app.py:207: error: Need type annotation for "licenses" [var-annotated]
- steam/role.py:64: error: MemberT? has no attribute "roles" [attr-defined]
- steam/badge.py:29: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/badge.py:40: error: Variable "steam.badge.AppT" is not valid as a type [valid-type]
- steam/badge.py:40: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:43: error: Variable "steam.badge.AppT" is not valid as a type [valid-type]
- steam/badge.py:43: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:56: error: Unsupported left operand type for == (AppT?) [operator]
- steam/badge.py:66: error: AppT? has no attribute "badges" [attr-defined]
- steam/badge.py:73: error: AppT? has no attribute "badges" [attr-defined]
- steam/badge.py:79: error: "BaseBadge" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:79: error: Variable "steam.badge.AppT" is not valid as a type [valid-type]
- steam/badge.py:79: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:84: error: Variable "steam.badge.AppT" is not valid as a type [valid-type]
- steam/badge.py:84: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:102: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:102: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:111: error: Variable "steam.badge.AppT" is not valid as a type [valid-type]
- steam/badge.py:111: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:111: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:117: error: "Item" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:117: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:117: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:123: error: UserT? has no attribute "inventory" [attr-defined]
- steam/badge.py:129: error: "Item" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:129: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:129: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:139: error: "Item" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:139: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:139: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:150: error: "BaseOwnedBadge" expects no type arguments, but 2 given [type-arg]
- steam/badge.py:150: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:150: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:161: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:161: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:173: error: "BaseOwnedBadge" expects no type arguments, but 2 given [type-arg]
- steam/badge.py:173: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:173: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:178: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:178: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:197: error: "UserBadge" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:197: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:197: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:228: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:228: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/badge.py:238: error: "UserBadge" expects no type arguments, but 1 given [type-arg]
- steam/badge.py:238: error: Variable "steam.types.user.UserT" is not valid as a type [valid-type]
- steam/badge.py:238: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/app.py:77: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/app.py:81: error: Free type variable expected in Generic[...] [misc]
- steam/app.py:94: error: Variable "steam.app.NameT" is not valid as a type [valid-type]
- steam/app.py:94: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/app.py:143: error: "App" expects no type arguments, but 1 given [type-arg]
+ steam/app.py:438: error: Incompatible default for argument "name" (default has type "None", argument has type "NameT") [assignment]
+ steam/app.py:438: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ steam/app.py:438: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
- steam/app.py:424: error: "App" expects no type arguments, but 1 given [type-arg]
- steam/app.py:424: error: Variable "steam.app.NameT" is not valid as a type [valid-type]
- steam/app.py:424: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/app.py:438: error: Variable "steam.app.NameT" is not valid as a type [valid-type]
- steam/app.py:438: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/app.py:515: error: "Leaderboard" expects 1 type argument, but 2 given [type-arg]
- steam/app.py:541: error: "Leaderboard" expects 1 type argument, but 2 given [type-arg]
- steam/app.py:567: error: "Leaderboard" expects 1 type argument, but 2 given [type-arg]
- steam/app.py:881: error: Incompatible types in assignment (expression has type "PublishedFile", variable has type "PublishedFileDetails") [assignment]
+ steam/app.py:881: error: Incompatible types in assignment (expression has type "PublishedFile[PartialUser]", variable has type "PublishedFileDetails") [assignment]
- steam/app.py:887: error: UserT? has no attribute "id64" [attr-defined]
- steam/app.py:983: error: "AppBadge" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1002: error: "AppBadge" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1086: error: "PartialApp" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1159: error: "PartialApp" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1205: error: "PartialApp" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1275: error: "PartialApp" expects no type arguments, but 1 given [type-arg]
- steam/app.py:1386: error: "PartialApp" expects no type arguments, but 1 given [type-arg]
+ steam/app.py:1435: error: Need type annotation for "partial_dlc" [var-annotated]
... (truncated 900 lines) ...
discord.py (https://github.com/Rapptz/discord.py)
- discord/_types.py:32: error: Unexpected argument to "TypeVar()": "default" [misc]
- discord/_types.py:32: error: Unexpected keyword argument "default" for "TypeVar" [call-arg]
- note: "TypeVar" defined here
- discord/state.py:163: error: Free type variable expected in Generic[...] [misc]
- discord/state.py:166: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/state.py:166: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/state.py:1617: error: "ConnectionState" expects no type arguments, but 1 given [type-arg]
- discord/state.py:1617: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/state.py:1617: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/message.py:532: error: Incompatible return value type (got "ConnectionState | Message | None", expected "Message | None") [return-value]
+ discord/message.py:532: error: Incompatible return value type (got "ConnectionState[Any] | Message | None", expected "Message | None") [return-value]
- discord/interactions.py:93: error: Free type variable expected in Generic[...] [misc]
- discord/interactions.py:167: error: "ConnectionState" expects no type arguments, but 1 given [type-arg]
- discord/interactions.py:167: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:167: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:168: error: "ConnectionState" expects no type arguments, but 1 given [type-arg]
- discord/interactions.py:168: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:168: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:169: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:169: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:182: error: Incompatible types in assignment (expression has type "object", variable has type "ApplicationCommandInteractionData | MessageComponentInteractionData | ModalSubmitInteractionData | None") [assignment]
+ discord/interactions.py:182: error: Incompatible types in assignment (expression has type "object", variable has type "ChatInputApplicationCommandInteractionData | UserApplicationCommandInteractionData | MessageApplicationCommandInteractionData | ButtonMessageComponentInteractionData | SelectMessageComponentInteractionData | ModalSubmitInteractionData | None") [assignment]
- discord/interactions.py:244: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:244: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:255: error: Incompatible return value type (got "ConnectionState | Guild | None", expected "Guild | None") [return-value]
+ discord/interactions.py:255: error: Incompatible return value type (got "ConnectionState[ClientT] | Guild | None", expected "Guild | None") [return-value]
- discord/interactions.py:328: error: "InteractionResponse" expects no type arguments, but 1 given [type-arg]
- discord/interactions.py:328: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:328: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:574: error: Free type variable expected in Generic[...] [misc]
- discord/interactions.py:587: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/interactions.py:587: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:587: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:588: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/interactions.py:588: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/interactions.py:588: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/interactions.py:1071: error: Incompatible types in assignment (expression has type "_InteractionMessageState", base class "Message" defined the type as "ConnectionState") [assignment]
+ discord/interactions.py:1071: error: Incompatible types in assignment (expression has type "_InteractionMessageState", base class "Message" defined the type as "ConnectionState[Any]") [assignment]
- discord/client.py:285: error: "ConnectionState" expects no type arguments, but 1 given [type-arg]
+ discord/client.py:291: error: Incompatible types in assignment (expression has type "Callable[[], Client]", variable has type "Callable[..., Self]") [assignment]
+ discord/client.py:291: error: Incompatible return value type (got "Client", expected "Self") [return-value]
- discord/client.py:1164: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/client.py:1166: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/client.py:1450: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/client.py:1452: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/webhook/sync.py:404: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState") [assignment]
+ discord/webhook/sync.py:404: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState[Any]") [assignment]
- discord/webhook/async_.py:772: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState") [assignment]
+ discord/webhook/async_.py:772: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState[Any]") [assignment]
- discord/webhook/async_.py:1011: error: Incompatible return value type (got "ConnectionState | _WebhookState | Guild | None", expected "Guild | None") [return-value]
+ discord/webhook/async_.py:1011: error: Incompatible return value type (got "ConnectionState[Any] | _WebhookState | Guild | None", expected "Guild | None") [return-value]
- discord/ui/view.py:176: error: "Callable[[Any, Interaction, Any], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_type__" [attr-defined]
+ discord/ui/view.py:176: error: "Callable[[Any, Interaction[Any], Any], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_type__" [attr-defined]
- discord/ui/view.py:176: error: "Callable[[Any, Interaction, Any], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__" [attr-defined]
+ discord/ui/view.py:176: error: "Callable[[Any, Interaction[Any], Any], Coroutine[Any, Any, Any]]" has no attribute "__discord_ui_model_kwargs__" [attr-defined]
- discord/ui/item.py:45: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/ui/item.py:123: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/ui/item.py:123: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/ui/item.py:123: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/app_commands/tree.py:110: error: Free type variable expected in Generic[...] [misc]
- discord/app_commands/tree.py:126: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/app_commands/tree.py:126: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/app_commands/tree.py:127: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/app_commands/tree.py:127: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/app_commands/tree.py:128: error: ClientT? has no attribute "http" [attr-defined]
- discord/app_commands/tree.py:129: error: ClientT? has no attribute "_connection" [attr-defined]
- discord/app_commands/tree.py:173: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:177: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:179: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:213: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:217: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:219: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:774: error: "Interaction" expects no type arguments, but 1 given [type-arg]
- discord/app_commands/tree.py:774: error: Variable "discord._types.ClientT" is not valid as a type [valid-type]
- discord/app_commands/tree.py:774: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- discord/app_commands/tree.py:1054: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:1067: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:1069: error: ClientT? has no attribute "application_id" [attr-defined]
- discord/app_commands/tree.py:1077: error: "Interaction" expects no type arguments, but 1 given [type-arg]
... (truncated 87 lines) ...
|
@JelleZijlstra If you've got some time, I'd love to get this in before the next release. It would allow projects to start using Depending on time, I could even open a followup which would start using the |
Will take a look tonight |
tv_arg = self.get_typevarlike_argument( | ||
"TypeVar", param_name, param_value, context, allow_unbound_tvars=True | ||
) | ||
default = tv_arg or AnyType(TypeOfAny.from_error) | ||
elif param_name == "values": | ||
# Probably using obsolete syntax with values=(...). Explain the current syntax. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not related to your PR) I wonder when this did work, may have been before typing was in CPython
This PR updates the semantic analyzer to support most forms of TypeVars with defaults while also providing basic argument validation.
Ref: #14851