mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
Update pyright version
This commit is contained in:
parent
76666fbcf4
commit
4e03b170ef
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: Run Pyright
|
- name: Run Pyright
|
||||||
uses: jakebailey/pyright-action@v1
|
uses: jakebailey/pyright-action@v1
|
||||||
with:
|
with:
|
||||||
version: '1.1.316'
|
version: '1.1.351'
|
||||||
warnings: false
|
warnings: false
|
||||||
no-comments: ${{ matrix.python-version != '3.x' }}
|
no-comments: ${{ matrix.python-version != '3.x' }}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class Cooldown:
|
|||||||
:class:`Cooldown`
|
:class:`Cooldown`
|
||||||
A new instance of this cooldown.
|
A new instance of this cooldown.
|
||||||
"""
|
"""
|
||||||
return Cooldown(self.rate, self.per)
|
return self.__class__(self.rate, self.per)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<Cooldown rate: {self.rate} per: {self.per} window: {self._window} tokens: {self._tokens}>'
|
return f'<Cooldown rate: {self.rate} per: {self.per} window: {self._window} tokens: {self._tokens}>'
|
||||||
|
@ -638,7 +638,7 @@ class BaseChannelTransformer(Transformer):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise TypeError('Union type of channels must be entirely made up of channels') from None
|
raise TypeError('Union type of channels must be entirely made up of channels') from None
|
||||||
|
|
||||||
self._types: Tuple[Type[Any]] = channel_types
|
self._types: Tuple[Type[Any], ...] = channel_types
|
||||||
self._channel_types: List[ChannelType] = types
|
self._channel_types: List[ChannelType] = types
|
||||||
self._display_name = display_name
|
self._display_name = display_name
|
||||||
|
|
||||||
@ -780,11 +780,11 @@ def get_supported_annotation(
|
|||||||
# Check if there's an origin
|
# Check if there's an origin
|
||||||
origin = getattr(annotation, '__origin__', None)
|
origin = getattr(annotation, '__origin__', None)
|
||||||
if origin is Literal:
|
if origin is Literal:
|
||||||
args = annotation.__args__ # type: ignore
|
args = annotation.__args__
|
||||||
return (LiteralTransformer(args), MISSING, True)
|
return (LiteralTransformer(args), MISSING, True)
|
||||||
|
|
||||||
if origin is Choice:
|
if origin is Choice:
|
||||||
arg = annotation.__args__[0] # type: ignore
|
arg = annotation.__args__[0]
|
||||||
return (ChoiceTransformer(arg), MISSING, True)
|
return (ChoiceTransformer(arg), MISSING, True)
|
||||||
|
|
||||||
if origin is not Union:
|
if origin is not Union:
|
||||||
@ -792,7 +792,7 @@ def get_supported_annotation(
|
|||||||
raise TypeError(f'unsupported type annotation {annotation!r}')
|
raise TypeError(f'unsupported type annotation {annotation!r}')
|
||||||
|
|
||||||
default = MISSING
|
default = MISSING
|
||||||
args = annotation.__args__ # type: ignore
|
args = annotation.__args__
|
||||||
if args[-1] is _none:
|
if args[-1] is _none:
|
||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
underlying = args[0]
|
underlying = args[0]
|
||||||
|
@ -429,7 +429,7 @@ class Asset(AssetMixin):
|
|||||||
url = url.with_query(url.raw_query_string)
|
url = url.with_query(url.raw_query_string)
|
||||||
|
|
||||||
url = str(url)
|
url = str(url)
|
||||||
return Asset(state=self._state, url=url, key=self._key, animated=self._animated)
|
return self.__class__(state=self._state, url=url, key=self._key, animated=self._animated)
|
||||||
|
|
||||||
def with_size(self, size: int, /) -> Self:
|
def with_size(self, size: int, /) -> Self:
|
||||||
"""Returns a new asset with the specified size.
|
"""Returns a new asset with the specified size.
|
||||||
@ -457,7 +457,7 @@ class Asset(AssetMixin):
|
|||||||
raise ValueError('size must be a power of 2 between 16 and 4096')
|
raise ValueError('size must be a power of 2 between 16 and 4096')
|
||||||
|
|
||||||
url = str(yarl.URL(self._url).with_query(size=size))
|
url = str(yarl.URL(self._url).with_query(size=size))
|
||||||
return Asset(state=self._state, url=url, key=self._key, animated=self._animated)
|
return self.__class__(state=self._state, url=url, key=self._key, animated=self._animated)
|
||||||
|
|
||||||
def with_format(self, format: ValidAssetFormatTypes, /) -> Self:
|
def with_format(self, format: ValidAssetFormatTypes, /) -> Self:
|
||||||
"""Returns a new asset with the specified format.
|
"""Returns a new asset with the specified format.
|
||||||
@ -492,7 +492,7 @@ class Asset(AssetMixin):
|
|||||||
url = yarl.URL(self._url)
|
url = yarl.URL(self._url)
|
||||||
path, _ = os.path.splitext(url.path)
|
path, _ = os.path.splitext(url.path)
|
||||||
url = str(url.with_path(f'{path}.{format}').with_query(url.raw_query_string))
|
url = str(url.with_path(f'{path}.{format}').with_query(url.raw_query_string))
|
||||||
return Asset(state=self._state, url=url, key=self._key, animated=self._animated)
|
return self.__class__(state=self._state, url=url, key=self._key, animated=self._animated)
|
||||||
|
|
||||||
def with_static_format(self, format: ValidStaticFormatTypes, /) -> Self:
|
def with_static_format(self, format: ValidStaticFormatTypes, /) -> Self:
|
||||||
"""Returns a new asset with the specified static format.
|
"""Returns a new asset with the specified static format.
|
||||||
|
@ -541,7 +541,7 @@ class AutoModRule:
|
|||||||
**payload,
|
**payload,
|
||||||
)
|
)
|
||||||
|
|
||||||
return AutoModRule(data=data, guild=self.guild, state=self._state)
|
return self.__class__(data=data, guild=self.guild, state=self._state)
|
||||||
|
|
||||||
async def delete(self, *, reason: str = MISSING) -> None:
|
async def delete(self, *, reason: str = MISSING) -> None:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
@ -315,7 +315,7 @@ class Client:
|
|||||||
def _get_websocket(self, guild_id: Optional[int] = None, *, shard_id: Optional[int] = None) -> DiscordWebSocket:
|
def _get_websocket(self, guild_id: Optional[int] = None, *, shard_id: Optional[int] = None) -> DiscordWebSocket:
|
||||||
return self.ws
|
return self.ws
|
||||||
|
|
||||||
def _get_state(self, **options: Any) -> ConnectionState:
|
def _get_state(self, **options: Any) -> ConnectionState[Self]:
|
||||||
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers, hooks=self._hooks, http=self.http, **options)
|
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers, hooks=self._hooks, http=self.http, **options)
|
||||||
|
|
||||||
def _handle_ready(self) -> None:
|
def _handle_ready(self) -> None:
|
||||||
|
@ -175,7 +175,7 @@ class Colour:
|
|||||||
return cls.from_rgb(*(int(x * 255) for x in rgb))
|
return cls.from_rgb(*(int(x * 255) for x in rgb))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_str(cls, value: str) -> Self:
|
def from_str(cls, value: str) -> Colour:
|
||||||
"""Constructs a :class:`Colour` from a string.
|
"""Constructs a :class:`Colour` from a string.
|
||||||
|
|
||||||
The following formats are accepted:
|
The following formats are accepted:
|
||||||
|
@ -75,9 +75,6 @@ __all__ = (
|
|||||||
'EntitlementOwnerType',
|
'EntitlementOwnerType',
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from typing_extensions import Self
|
|
||||||
|
|
||||||
|
|
||||||
def _create_value_cls(name: str, comparable: bool):
|
def _create_value_cls(name: str, comparable: bool):
|
||||||
# All the type ignores here are due to the type checker being unable to recognise
|
# All the type ignores here are due to the type checker being unable to recognise
|
||||||
@ -104,7 +101,14 @@ class EnumMeta(type):
|
|||||||
_enum_member_map_: ClassVar[Dict[str, Any]]
|
_enum_member_map_: ClassVar[Dict[str, Any]]
|
||||||
_enum_value_map_: ClassVar[Dict[Any, Any]]
|
_enum_value_map_: ClassVar[Dict[Any, Any]]
|
||||||
|
|
||||||
def __new__(cls, name: str, bases: Tuple[type, ...], attrs: Dict[str, Any], *, comparable: bool = False) -> Self:
|
def __new__(
|
||||||
|
cls,
|
||||||
|
name: str,
|
||||||
|
bases: Tuple[type, ...],
|
||||||
|
attrs: Dict[str, Any],
|
||||||
|
*,
|
||||||
|
comparable: bool = False,
|
||||||
|
) -> EnumMeta:
|
||||||
value_mapping = {}
|
value_mapping = {}
|
||||||
member_mapping = {}
|
member_mapping = {}
|
||||||
member_names = []
|
member_names = []
|
||||||
|
@ -169,7 +169,7 @@ class CogMeta(type):
|
|||||||
__cog_app_commands__: List[Union[app_commands.Group, app_commands.Command[Any, ..., Any]]]
|
__cog_app_commands__: List[Union[app_commands.Group, app_commands.Command[Any, ..., Any]]]
|
||||||
__cog_listeners__: List[Tuple[str, str]]
|
__cog_listeners__: List[Tuple[str, str]]
|
||||||
|
|
||||||
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
|
def __new__(cls, *args: Any, **kwargs: Any) -> CogMeta:
|
||||||
name, bases, attrs = args
|
name, bases, attrs = args
|
||||||
if any(issubclass(base, app_commands.Group) for base in bases):
|
if any(issubclass(base, app_commands.Group) for base in bases):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
@ -366,7 +366,7 @@ class Cog(metaclass=CogMeta):
|
|||||||
child.wrapped = lookup[child.qualified_name] # type: ignore
|
child.wrapped = lookup[child.qualified_name] # type: ignore
|
||||||
|
|
||||||
if self.__cog_app_commands_group__:
|
if self.__cog_app_commands_group__:
|
||||||
children.append(app_command) # type: ignore # Somehow it thinks it can be None here
|
children.append(app_command)
|
||||||
|
|
||||||
if Cog._get_overridden_method(self.cog_app_command_error) is not None:
|
if Cog._get_overridden_method(self.cog_app_command_error) is not None:
|
||||||
error_handler = self.cog_app_command_error
|
error_handler = self.cog_app_command_error
|
||||||
|
@ -1185,7 +1185,7 @@ def _convert_to_bool(argument: str) -> bool:
|
|||||||
raise BadBoolArgument(lowered)
|
raise BadBoolArgument(lowered)
|
||||||
|
|
||||||
|
|
||||||
_GenericAlias = type(List[T])
|
_GenericAlias = type(List[T]) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def is_generic_type(tp: Any, *, _GenericAlias: type = _GenericAlias) -> bool:
|
def is_generic_type(tp: Any, *, _GenericAlias: type = _GenericAlias) -> bool:
|
||||||
|
@ -461,7 +461,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
|
|
||||||
# bandaid for the fact that sometimes parent can be the bot instance
|
# bandaid for the fact that sometimes parent can be the bot instance
|
||||||
parent: Optional[GroupMixin[Any]] = kwargs.get('parent')
|
parent: Optional[GroupMixin[Any]] = kwargs.get('parent')
|
||||||
self.parent: Optional[GroupMixin[Any]] = parent if isinstance(parent, _BaseCommand) else None # type: ignore # Does not recognise mixin usage
|
self.parent: Optional[GroupMixin[Any]] = parent if isinstance(parent, _BaseCommand) else None
|
||||||
|
|
||||||
self._before_invoke: Optional[Hook] = None
|
self._before_invoke: Optional[Hook] = None
|
||||||
try:
|
try:
|
||||||
@ -776,7 +776,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
command = self
|
command = self
|
||||||
# command.parent is type-hinted as GroupMixin some attributes are resolved via MRO
|
# command.parent is type-hinted as GroupMixin some attributes are resolved via MRO
|
||||||
while command.parent is not None: # type: ignore
|
while command.parent is not None: # type: ignore
|
||||||
command = command.parent
|
command = command.parent # type: ignore
|
||||||
entries.append(command.name) # type: ignore
|
entries.append(command.name) # type: ignore
|
||||||
|
|
||||||
return ' '.join(reversed(entries))
|
return ' '.join(reversed(entries))
|
||||||
@ -794,7 +794,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
entries = []
|
entries = []
|
||||||
command = self
|
command = self
|
||||||
while command.parent is not None: # type: ignore
|
while command.parent is not None: # type: ignore
|
||||||
command = command.parent
|
command = command.parent # type: ignore
|
||||||
entries.append(command)
|
entries.append(command)
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
@ -280,7 +280,7 @@ class FlagsMeta(type):
|
|||||||
case_insensitive: bool = MISSING,
|
case_insensitive: bool = MISSING,
|
||||||
delimiter: str = MISSING,
|
delimiter: str = MISSING,
|
||||||
prefix: str = MISSING,
|
prefix: str = MISSING,
|
||||||
) -> Self:
|
) -> FlagsMeta:
|
||||||
attrs['__commands_is_flag__'] = True
|
attrs['__commands_is_flag__'] = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -902,7 +902,7 @@ def hybrid_command(
|
|||||||
def decorator(func: CommandCallback[CogT, ContextT, P, T]) -> HybridCommand[CogT, P, T]:
|
def decorator(func: CommandCallback[CogT, ContextT, P, T]) -> HybridCommand[CogT, P, T]:
|
||||||
if isinstance(func, Command):
|
if isinstance(func, Command):
|
||||||
raise TypeError('Callback is already a command.')
|
raise TypeError('Callback is already a command.')
|
||||||
return HybridCommand(func, name=name, with_app_command=with_app_command, **attrs) # type: ignore # ???
|
return HybridCommand(func, name=name, with_app_command=with_app_command, **attrs)
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class File:
|
|||||||
else:
|
else:
|
||||||
filename = getattr(fp, 'name', 'untitled')
|
filename = getattr(fp, 'name', 'untitled')
|
||||||
|
|
||||||
self._filename, filename_spoiler = _strip_spoiler(filename)
|
self._filename, filename_spoiler = _strip_spoiler(filename) # type: ignore # pyright doesn't understand the above getattr
|
||||||
if spoiler is MISSING:
|
if spoiler is MISSING:
|
||||||
spoiler = filename_spoiler
|
spoiler = filename_spoiler
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ __all__ = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing_extensions import TypeAlias, Self, TypeGuard
|
from typing_extensions import TypeAlias, TypeGuard
|
||||||
|
|
||||||
from .view import View
|
from .view import View
|
||||||
from ..types.components import SelectMenu as SelectMenuPayload
|
from ..types.components import SelectMenu as SelectMenuPayload
|
||||||
@ -342,7 +342,7 @@ class BaseSelect(Item[V]):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_component(cls, component: SelectMenu) -> Self:
|
def from_component(cls, component: SelectMenu) -> BaseSelect[V]:
|
||||||
type_to_cls: Dict[ComponentType, Type[BaseSelect[Any]]] = {
|
type_to_cls: Dict[ComponentType, Type[BaseSelect[Any]]] = {
|
||||||
ComponentType.string_select: Select,
|
ComponentType.string_select: Select,
|
||||||
ComponentType.user_select: UserSelect,
|
ComponentType.user_select: UserSelect,
|
||||||
@ -887,7 +887,7 @@ class ChannelSelect(BaseSelect[V]):
|
|||||||
@overload
|
@overload
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[SelectT] = Select[V],
|
cls: Type[SelectT] = Select[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = ...,
|
channel_types: List[ChannelType] = ...,
|
||||||
placeholder: Optional[str] = ...,
|
placeholder: Optional[str] = ...,
|
||||||
@ -903,7 +903,7 @@ def select(
|
|||||||
@overload
|
@overload
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[UserSelectT] = UserSelect[V],
|
cls: Type[UserSelectT] = UserSelect[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = ...,
|
channel_types: List[ChannelType] = ...,
|
||||||
placeholder: Optional[str] = ...,
|
placeholder: Optional[str] = ...,
|
||||||
@ -920,7 +920,7 @@ def select(
|
|||||||
@overload
|
@overload
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[RoleSelectT] = RoleSelect[V],
|
cls: Type[RoleSelectT] = RoleSelect[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = ...,
|
channel_types: List[ChannelType] = ...,
|
||||||
placeholder: Optional[str] = ...,
|
placeholder: Optional[str] = ...,
|
||||||
@ -937,7 +937,7 @@ def select(
|
|||||||
@overload
|
@overload
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[ChannelSelectT] = ChannelSelect[V],
|
cls: Type[ChannelSelectT] = ChannelSelect[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = ...,
|
channel_types: List[ChannelType] = ...,
|
||||||
placeholder: Optional[str] = ...,
|
placeholder: Optional[str] = ...,
|
||||||
@ -954,7 +954,7 @@ def select(
|
|||||||
@overload
|
@overload
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[MentionableSelectT] = MentionableSelect[V],
|
cls: Type[MentionableSelectT] = MentionableSelect[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = MISSING,
|
channel_types: List[ChannelType] = MISSING,
|
||||||
placeholder: Optional[str] = ...,
|
placeholder: Optional[str] = ...,
|
||||||
@ -970,7 +970,7 @@ def select(
|
|||||||
|
|
||||||
def select(
|
def select(
|
||||||
*,
|
*,
|
||||||
cls: Type[BaseSelectT] = Select[V],
|
cls: Type[BaseSelectT] = Select[Any],
|
||||||
options: List[SelectOption] = MISSING,
|
options: List[SelectOption] = MISSING,
|
||||||
channel_types: List[ChannelType] = MISSING,
|
channel_types: List[ChannelType] = MISSING,
|
||||||
placeholder: Optional[str] = None,
|
placeholder: Optional[str] = None,
|
||||||
|
@ -721,7 +721,7 @@ async def sane_wait_for(futures: Iterable[Awaitable[T]], *, timeout: Optional[fl
|
|||||||
def get_slots(cls: Type[Any]) -> Iterator[str]:
|
def get_slots(cls: Type[Any]) -> Iterator[str]:
|
||||||
for mro in reversed(cls.__mro__):
|
for mro in reversed(cls.__mro__):
|
||||||
try:
|
try:
|
||||||
yield from mro.__slots__ # type: ignore
|
yield from mro.__slots__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -214,4 +214,4 @@ class WelcomeScreen:
|
|||||||
fields['enabled'] = enabled
|
fields['enabled'] = enabled
|
||||||
|
|
||||||
data = await self._state.http.edit_welcome_screen(self._guild.id, reason=reason, **fields)
|
data = await self._state.http.edit_welcome_screen(self._guild.id, reason=reason, **fields)
|
||||||
return WelcomeScreen(data=data, guild=self._guild)
|
return self.__class__(data=data, guild=self._guild)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user