ruff
229cb6eb - [ty] Skip method signature inference for concrete decorator results (#29708)

Commit
27 days ago
[ty] Skip method signature inference for concrete decorator results (#29708) ## Summary Checking [`discord/state.py`](https://github.com/Rapptz/discord.py/blob/65232c38702be5844cf2ce865a4777eb1928b5d0/discord/state.py) opened 100 Python files instead of 112. To decide whether `Interaction` was abstract, we used to follow the return annotation on [`Interaction.command`](https://github.com/Rapptz/discord.py/blob/65232c38702be5844cf2ce865a4777eb1928b5d0/discord/interactions.py#L355) into `discord.ext.commands`. ```python def cached_slot_property[Owner, Value]( name: str, ) -> Callable[[Callable[[Owner], Value]], CachedSlotProperty[Owner, Value]]: ... class Interaction: @cached_slot_property("_cs_command") def command(self) -> Command[Any, ..., Any] | ContextMenu | None: ... ``` The decorator always returns a `CachedSlotProperty`. The return annotation on `command` determines the type of the cached value, but it cannot make the descriptor abstract. We now skip the method’s signature when its sole decorator rules out an abstract method or property. Checking all of discord.py showed no measurable speedup.
Author
Parents
Loading