Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jun 18, 2024

We used a custom syntax for type variable bounds and restrictions. Use PEP 695 syntax instead (or at least something closer to PEP 695 syntax).

We used a custom syntax for type variable bounds and restrictions. Use
PEP 695 syntax instead (or at least something closer to PEP 695 syntax).
@github-actions

This comment has been minimized.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jun 18, 2024

This conflicts with #17392. I will wait until #17392 is merged and will fix the conflicts here.

@github-actions
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/gateway.py:825: note:     def [MsgT <: Message] wait_for(self, type[MsgT], /, *, check: Callable[[MsgT], bool] = ...) -> Future[MsgT]
+ steam/gateway.py:825: note:     def [MsgT: Message] wait_for(self, type[MsgT], /, *, check: Callable[[MsgT], bool] = ...) -> Future[MsgT]
- steam/gateway.py:825: note:     def [ProtoMsgT <: ProtobufMessage] wait_for(self, type[ProtoMsgT], /, *, check: Callable[[ProtoMsgT], bool] = ...) -> Future[ProtoMsgT]
+ steam/gateway.py:825: note:     def [ProtoMsgT: ProtobufMessage] wait_for(self, type[ProtoMsgT], /, *, check: Callable[[ProtoMsgT], bool] = ...) -> Future[ProtoMsgT]

discord.py (https://github.com/Rapptz/discord.py)
- discord/ui/modal.py:152: note:          def [ClientT <: Client] on_error(self, Interaction[ClientT], Exception, /) -> Coroutine[Any, Any, None]
+ discord/ui/modal.py:152: note:          def [ClientT: Client] on_error(self, Interaction[ClientT], Exception, /) -> Coroutine[Any, Any, None]
- discord/ext/commands/hybrid.py:814: note:          def [CommandT <: Command[Any, [VarArg(Any), KwArg(Any)], Any]] command(self, name: str = ..., cls: type[CommandT] = ..., *args: Any, **kwargs: Any) -> Callable[[Callable[[CogT, ContextT, **P], Coroutine[Any, Any, T]] | Callable[[ContextT, **P], Coroutine[Any, Any, T]]], CommandT]
+ discord/ext/commands/hybrid.py:814: note:          def [CommandT: Command[Any, [VarArg(Any), KwArg(Any)], Any]] command(self, name: str = ..., cls: type[CommandT] = ..., *args: Any, **kwargs: Any) -> Callable[[Callable[[CogT, ContextT, **P], Coroutine[Any, Any, T]] | Callable[[ContextT, **P], Coroutine[Any, Any, T]]], CommandT]
- discord/ext/commands/hybrid.py:838: note:          def [GroupT <: Group[Any, [VarArg(Any), KwArg(Any)], Any]] group(self, name: str = ..., cls: type[GroupT] = ..., *args: Any, **kwargs: Any) -> Callable[[Callable[[CogT, ContextT, **P], Coroutine[Any, Any, T]] | Callable[[ContextT, **P], Coroutine[Any, Any, T]]], GroupT]
+ discord/ext/commands/hybrid.py:838: note:          def [GroupT: Group[Any, [VarArg(Any), KwArg(Any)], Any]] group(self, name: str = ..., cls: type[GroupT] = ..., *args: Any, **kwargs: Any) -> Callable[[Callable[[CogT, ContextT, **P], Coroutine[Any, Any, T]] | Callable[[ContextT, **P], Coroutine[Any, Any, T]]], GroupT]

pydantic (https://github.com/samuelcolvin/pydantic)
- pydantic/v1/generics.py:124: note:     def [Model <: BaseModel] create_model(str, /, *, __config__: type[BaseConfig] | None = ..., __base__: type[Model] | tuple[type[Model], ...], __module__: str = ..., __validators__: dict[str, classmethod[Any, Any, Any]] = ..., __cls_kwargs__: dict[str, Any] = ..., **field_definitions: Any) -> type[Model]
+ pydantic/v1/generics.py:124: note:     def [Model: BaseModel] create_model(str, /, *, __config__: type[BaseConfig] | None = ..., __base__: type[Model] | tuple[type[Model], ...], __module__: str = ..., __validators__: dict[str, classmethod[Any, Any, Any]] = ..., __cls_kwargs__: dict[str, Any] = ..., **field_definitions: Any) -> type[Model]

@JukkaL JukkaL merged commit 6877d6f into master Jun 20, 2024
@JukkaL JukkaL deleted the message-generic-callable branch June 20, 2024 09:01
@davidhalter
Copy link

@JukkaL Just FYI: I think it's a bit confusing that TypeStrVisitor.visit_callable_type still uses the old syntax (this causes old syntax in all reveal_type() calls). I have unfortunately no time to fix it now.

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.

4 participants