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

Use TypeVar defaults instead of Any when fixing instance types (PEP 696) #16812

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 24, 2024

Start using TypeVar defaults when fixing instance types, instead of filling those with Any.
This PR preserves the way an invalid amount of args is handled. I.e. filling all with Any / defaults, instead of cutting off additional args. Thus preserving full backwards compatibility. This can be easily changed later if necessary.

TypeVarTuple defaults aren't handled correctly yet. Those will require additional logic which would have complicated the change here and made it more difficult to review.

Ref: #14851

@cdce8p cdce8p changed the title Use TypeVar defaults instead of Any when fixing instance (PEP 696) Use TypeVar defaults instead of Any when fixing instance types (PEP 696) Jan 24, 2024
Copy link
Contributor

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

steam.py (https://github.com/Gobot1234/steam.py)
- steam/badge.py:129: error: Argument 1 to "inventory" of "PartialUser" has incompatible type "tuple[str, int]"; expected "App[Any]"  [arg-type]
+ steam/badge.py:129: error: Argument 1 to "inventory" of "PartialUser" has incompatible type "tuple[str, int]"; expected "App[str]"  [arg-type]
- steam/badge.py:155: error: "BaseOwnedBadge" expects 2 type arguments, but 1 given  [type-arg]
+ steam/app.py:696: error: Argument 2 to "AppStats" has incompatible type "PartialApp[NameT]"; expected "App[str]"  [arg-type]
+ steam/app.py:710: error: Argument 2 to "AppAchievement" has incompatible type "PartialApp[NameT]"; expected "PartialApp[str]"  [arg-type]
+ steam/app.py:724: error: Type argument "Self" of "Leaderboard" must be a subtype of "App[str]"  [type-var]
+ steam/app.py:736: error: Value of type variable "AppT" of "Leaderboard" cannot be "Self"  [type-var]
+ steam/app.py:749: error: Type argument "Self" of "Leaderboard" must be a subtype of "App[str]"  [type-var]
+ steam/app.py:765: error: Value of type variable "AppT" of "Leaderboard" cannot be "Self"  [type-var]
+ steam/app.py:775: error: Type argument "Self" of "Leaderboard" must be a subtype of "App[str]"  [type-var]
+ steam/app.py:786: error: Value of type variable "AppT" of "Leaderboard" cannot be "Self"  [type-var]
+ steam/app.py:832: error: Argument 1 to "fetch_review" of "PartialUser" has incompatible type "PartialApp[NameT]"; expected "App[str]"  [arg-type]
+ steam/app.py:1169: error: Type argument "Self" of "CommunityItem" must be a subtype of "PartialApp[str]"  [type-var]
+ steam/app.py:1181: error: Value of type variable "AppT" of "CommunityItem" cannot be "Self"  [type-var]
+ steam/app.py:1230: error: Type argument "Self" of "RewardItem" must be a subtype of "PartialApp[str]"  [type-var]
+ steam/app.py:1240: error: Value of type variable "AppT" of "RewardItem" cannot be "Self"  [type-var]
+ steam/app.py:1271: error: Value of type variable "AppT" of "AppBadge" cannot be "Self"  [type-var]
+ steam/app.py:1300: error: Type argument "Self" of "RewardItem" must be a subtype of "PartialApp[str]"  [type-var]
+ steam/app.py:1305: error: Type argument "Self" of "AppBadge" must be a subtype of "PartialApp[str]"  [type-var]
+ steam/app.py:1316: error: Value of type variable "AppT" of "AppBadge" cannot be "Self"  [type-var]
+ steam/app.py:1374: error: Argument 1 to "temporarily_play" of "ConnectionState" has incompatible type "PartialApp[NameT]"; expected "App[str]"  [arg-type]
- steam/profile.py:152: error: Argument 1 to "inventory" of "PartialUser" has incompatible type "tuple[str, int]"; expected "App[Any]"  [arg-type]
+ steam/profile.py:152: error: Argument 1 to "inventory" of "PartialUser" has incompatible type "tuple[str, int]"; expected "App[str]"  [arg-type]
- steam/abc.py:199: error: "Comment" expects 2 type arguments, but 1 given  [type-arg]
- steam/abc.py:208: error: "Comment" expects 2 type arguments, but 1 given  [type-arg]
+ steam/abc.py:231: error: Need type annotation for "comments"  [var-annotated]
- steam/abc.py:546: error: "FavouriteBadge" expects 2 type arguments, but 1 given  [type-arg]
- steam/event.py:182: error: "Event" expects 2 type arguments, but 1 given  [type-arg]
- steam/event.py:277: error: Incompatible types in assignment (expression has type "App[Any] | PartialApp[str | None] | None", variable has type "PartialApp[str | None] | None")  [assignment]
+ steam/event.py:277: error: Incompatible types in assignment (expression has type "App[str] | PartialApp[str | None] | None", variable has type "PartialApp[str | None] | None")  [assignment]
- steam/chat.py:177: error: "ChatGroup" expects 3 type arguments, but 2 given  [type-arg]
- steam/chat.py:334: error: "ChatGroup" expects 3 type arguments, but 2 given  [type-arg]
+ steam/user_news.py:112: error: Argument 1 to "fetch_review" of "PartialUser" has incompatible type "PartialApp[str | None]"; expected "App[str]"  [arg-type]
- steam/state.py:2442: error: Argument 2 to "__get__" of "classproperty" has incompatible type "type[Awardable[Any]]"; expected "type[Self]"  [arg-type]
+ steam/state.py:2442: error: Argument 2 to "__get__" of "classproperty" has incompatible type "type[Awardable[int]]"; expected "type[Self]"  [arg-type]
- steam/ext/commands/context.py:59: error: "Message" expects 2 type arguments, but 1 given  [type-arg]
- steam/ext/commands/context.py:110: error: "Message" expects 2 type arguments, but 1 given  [type-arg]
- steam/ext/commands/converters.py:324: error: "Channel" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/converters.py:450: error: "Channel" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/converters.py:481: error: Unused "type: ignore" comment  [unused-ignore]
- steam/ext/commands/commands.py:203: error: "Group" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:288: error: Incompatible types in assignment (expression has type "GroupMixin[Any] | Group[Any, Any, Any] | None", variable has type "Self")  [assignment]
+ steam/ext/commands/commands.py:288: error: Incompatible types in assignment (expression has type "GroupMixin[Any] | Group[Any, [VarArg(Any), KwArg(Any)], Any] | None", variable has type "Self")  [assignment]
- steam/ext/commands/commands.py:592: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:592: error: Incompatible types in assignment (expression has type "object", variable has type "dict[str, Command[Any, Any, Any]]")  [assignment]
+ steam/ext/commands/commands.py:592: error: Incompatible types in assignment (expression has type "object", variable has type "dict[str, Command[CogT, [VarArg(Any), KwArg(Any)], Any]]")  [assignment]
- steam/ext/commands/commands.py:596: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:601: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:606: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:608: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:616: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:641: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/commands.py:662: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
+ steam/ext/commands/commands.py:747: error: Overloaded function signatures 2 and 3 overlap with incompatible return types  [overload-overlap]
- steam/ext/commands/commands.py:847: error: "Group" expects 3 type arguments, but 1 given  [type-arg]
+ steam/ext/commands/commands.py:865: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables  [misc]
- steam/ext/commands/commands.py:933: error: Argument 1 to "append" of "list" has incompatible type overloaded function; expected "Check[Any]"  [arg-type]
+ steam/ext/commands/commands.py:933: error: Argument 1 to "append" of "list" has incompatible type overloaded function; expected "Check[bool | Coroutine[Any, Any, bool]]"  [arg-type]
- steam/ext/commands/cog.py:31: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/cog.py:107: error: "Command" expects 3 type arguments, but 1 given  [type-arg]
- steam/ext/commands/bot.py:521: error: "Message" expects 2 type arguments, but 1 given  [type-arg]
- steam/ext/tf2/currency.py:147: error: "Item[Any]" has no attribute "name"  [attr-defined]
+ steam/ext/tf2/currency.py:147: error: "Item[BaseUser]" has no attribute "name"  [attr-defined]
- steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[Any], *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
+ steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[str], *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
- steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[Any], *, language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
+ steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[str], *, language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
- steam/ext/csgo/models.py:179: note:          def inventory(self, App[Any], /, *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
+ steam/ext/csgo/models.py:179: note:          def inventory(self, App[str], /, *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
- steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[Any], *, language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
+ steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[str], *, language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
- steam/ext/csgo/models.py:179: note:          def inventory(self, App[Any], /, *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
+ steam/ext/csgo/models.py:179: note:          def inventory(self, App[str], /, *, context_id: int | None = ..., language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]
- steam/ext/csgo/models.py:179: note:          def inventory(self, app: App[Any], *, language: Language | None = ...) -> Coroutine[Any, Any, Inventory[Item[ClientUser], ClientUser]]

... (truncated 13 lines) ...

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/udf.py:43: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/structs.py:14: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:17: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:59: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:60: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:61: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:69: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:70: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:78: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:79: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:87: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:88: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:89: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:90: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:98: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:99: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:100: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:108: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:109: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:110: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:118: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:119: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:120: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:128: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:129: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:137: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:138: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:149: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:150: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:158: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:167: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:176: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:177: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:185: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:186: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:202: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:203: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:204: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:212: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:213: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:224: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:225: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:226: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:234: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:235: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:236: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:244: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:245: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:253: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:261: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:299: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:319: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:320: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:328: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/strings.py:329: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:14: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:15: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:16: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:68: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:75: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:82: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/numeric.py:169: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:13: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:14: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:28: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:34: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:35: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:47: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:48: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:56: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:65: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:74: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/maps.py:75: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:30: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:38: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:39: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:40: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:48: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:49: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:60: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:73: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:74: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:82: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:95: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:96: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:105: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:116: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:125: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:134: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:143: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:151: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:159: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:160: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:168: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:169: error: "Value" expects 2 type arguments, but 1 given  [type-arg]
- ibis/expr/operations/arrays.py:177: error: "Value" expects 2 type arguments, but 1 given  [type-arg]

... (truncated 714 lines) ...

discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/models.py:615: error: Unused "type: ignore" comment  [unused-ignore]
- discord/app_commands/models.py:789: error: Unused "type: ignore" comment  [unused-ignore]
+ discord/shard.py:337: error: Incompatible types in assignment (expression has type "AutoShardedConnectionState[Client]", base class "Client" defined the type as "ConnectionState[AutoShardedClient]")  [assignment]
- discord/message.py:540: error: Incompatible return value type (got "ConnectionState[Any] | Message | None", expected "Message | None")  [return-value]
+ discord/message.py:540: error: Incompatible return value type (got "ConnectionState[Client] | Message | None", expected "Message | None")  [return-value]
- discord/interactions.py:1132: error: Incompatible types in assignment (expression has type "_InteractionMessageState", base class "Message" defined the type as "ConnectionState[Any]")  [assignment]
+ discord/interactions.py:1132: error: Incompatible types in assignment (expression has type "_InteractionMessageState", base class "Message" defined the type as "ConnectionState[Client]")  [assignment]
+ discord/client.py:288: error: Incompatible types in assignment (expression has type "ConnectionState[Client]", variable has type "ConnectionState[Self]")  [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/sync.py:404: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState[Client]")  [assignment]
- discord/webhook/async_.py:773: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState[Any]")  [assignment]
+ discord/webhook/async_.py:773: error: Incompatible types in assignment (expression has type "_WebhookState", base class "Message" defined the type as "ConnectionState[Client]")  [assignment]
- discord/webhook/async_.py:1012: error: Incompatible return value type (got "ConnectionState[Any] | _WebhookState | Guild | None", expected "Guild | None")  [return-value]
+ discord/webhook/async_.py:1012: error: Incompatible return value type (got "ConnectionState[Client] | _WebhookState | Guild | None", expected "Guild | None")  [return-value]
- discord/app_commands/commands.py:973: error: Argument 1 to "maybe_coroutine" has incompatible type "Callable[[Interaction[Any]], Coroutine[Any, Any, bool]]"; expected "Callable[[Interaction[Any]], Never | Awaitable[Never]]"  [arg-type]
+ discord/app_commands/commands.py:973: error: Argument 1 to "maybe_coroutine" has incompatible type "Callable[[Interaction[Client]], Coroutine[Any, Any, bool]]"; expected "Callable[[Interaction[Client]], Never | Awaitable[Never]]"  [arg-type]
- discord/ui/modal.py:151: note:          def on_error(self, Interaction[Any], Exception, Item[Any], /) -> Coroutine[Any, Any, None]
+ discord/ui/modal.py:151: note:          def on_error(self, Interaction[Client], Exception, Item[Any], /) -> Coroutine[Any, Any, None]
- discord/ui/modal.py:168: note:          def _refresh(self, interaction: Interaction[Any], components: Sequence[ModalSubmitActionRowInteractionData | ModalSubmitTextInputInteractionData]) -> None
+ discord/ui/modal.py:168: note:          def _refresh(self, interaction: Interaction[Client], components: Sequence[ModalSubmitActionRowInteractionData | ModalSubmitTextInputInteractionData]) -> None
- discord/ui/modal.py:179: error: Argument 2 of "_scheduled_task" is incompatible with supertype "View"; supertype defines the argument type as "Interaction[Any]"  [override]
+ discord/ui/modal.py:179: error: Argument 2 of "_scheduled_task" is incompatible with supertype "View"; supertype defines the argument type as "Interaction[Client]"  [override]
- discord/ext/commands/cog.py:549: error: "Callable[[Interaction[Any], AppCommandError], Coroutine[Any, Any, None]]" has no attribute "__func__"  [attr-defined]
+ discord/ext/commands/cog.py:549: error: "Callable[[Interaction[Client], AppCommandError], Coroutine[Any, Any, None]]" has no attribute "__func__"  [attr-defined]
- discord/ext/commands/hybrid.py:386: error: Unused "type: ignore" comment  [unused-ignore]
- discord/ext/commands/hybrid.py:401: error: Argument 1 to "maybe_coroutine" has incompatible type "Callable[[Interaction[Any]], Coroutine[Any, Any, bool]]"; expected "Callable[[Interaction[Any]], Never | Awaitable[Never]]"  [arg-type]
+ discord/ext/commands/hybrid.py:401: error: Argument 1 to "maybe_coroutine" has incompatible type "Callable[[Interaction[Client]], Coroutine[Any, Any, bool]]"; expected "Callable[[Interaction[Client]], Never | Awaitable[Never]]"  [arg-type]
- discord/ext/commands/hybrid.py:431: error: Unused "type: ignore" comment  [unused-ignore]

@JelleZijlstra JelleZijlstra merged commit ec06e00 into python:master Jan 24, 2024
18 checks passed
@cdce8p cdce8p deleted the TypeVar-05-fix-instances branch January 24, 2024 18:56
JelleZijlstra pushed a commit that referenced this pull request Jan 28, 2024
…696) (#16825)

This PR applies the TypeVar defaults to `TypeAlias` types instead of
using `Any` exclusively, similar to
#16812.
Again `TypeVarTuple` defaults aren't handled correctly yet.

Ref: #14851
@cdce8p cdce8p added the topic-pep-696 TypeVar defaults label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-pep-696 TypeVar defaults
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants