Reformat entire project with ruff instead of black

This commit is contained in:
Rapptz
2025-08-18 20:15:44 -04:00
parent 3ef6272e07
commit 44a44e938f
88 changed files with 485 additions and 730 deletions

View File

@ -158,8 +158,7 @@ if TYPE_CHECKING:
class _DecompressionContext(Protocol):
COMPRESSION_TYPE: str
def decompress(self, data: bytes, /) -> str | None:
...
def decompress(self, data: bytes, /) -> str | None: ...
P = ParamSpec('P')
@ -186,12 +185,10 @@ class CachedSlotProperty(Generic[T, T_co]):
self.__doc__ = getattr(function, '__doc__')
@overload
def __get__(self, instance: None, owner: Type[T]) -> CachedSlotProperty[T, T_co]:
...
def __get__(self, instance: None, owner: Type[T]) -> CachedSlotProperty[T, T_co]: ...
@overload
def __get__(self, instance: T, owner: Type[T]) -> T_co:
...
def __get__(self, instance: T, owner: Type[T]) -> T_co: ...
def __get__(self, instance: Optional[T], owner: Type[T]) -> Any:
if instance is None:
@ -240,15 +237,13 @@ class SequenceProxy(Sequence[T_co]):
return self.__proxied
def __repr__(self) -> str:
return f"SequenceProxy({self.__proxied!r})"
return f'SequenceProxy({self.__proxied!r})'
@overload
def __getitem__(self, idx: SupportsIndex) -> T_co:
...
def __getitem__(self, idx: SupportsIndex) -> T_co: ...
@overload
def __getitem__(self, idx: slice) -> List[T_co]:
...
def __getitem__(self, idx: slice) -> List[T_co]: ...
def __getitem__(self, idx: Union[SupportsIndex, slice]) -> Union[T_co, List[T_co]]:
return self.__copied[idx]
@ -273,18 +268,15 @@ class SequenceProxy(Sequence[T_co]):
@overload
def parse_time(timestamp: None) -> None:
...
def parse_time(timestamp: None) -> None: ...
@overload
def parse_time(timestamp: str) -> datetime.datetime:
...
def parse_time(timestamp: str) -> datetime.datetime: ...
@overload
def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]:
...
def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]: ...
def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]:
@ -308,7 +300,7 @@ def deprecated(instead: Optional[str] = None) -> Callable[[Callable[P, T]], Call
def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
warnings.simplefilter('always', DeprecationWarning) # turn off filter
if instead:
fmt = "{0.__name__} is deprecated, use {1} instead."
fmt = '{0.__name__} is deprecated, use {1} instead.'
else:
fmt = '{0.__name__} is deprecated.'
@ -447,13 +439,11 @@ async def _afind(predicate: Callable[[T], Any], iterable: AsyncIterable[T], /) -
@overload
def find(predicate: Callable[[T], Any], iterable: AsyncIterable[T], /) -> Coro[Optional[T]]:
...
def find(predicate: Callable[[T], Any], iterable: AsyncIterable[T], /) -> Coro[Optional[T]]: ...
@overload
def find(predicate: Callable[[T], Any], iterable: Iterable[T], /) -> Optional[T]:
...
def find(predicate: Callable[[T], Any], iterable: Iterable[T], /) -> Optional[T]: ...
def find(predicate: Callable[[T], Any], iterable: _Iter[T], /) -> Union[Optional[T], Coro[Optional[T]]]:
@ -533,13 +523,11 @@ async def _aget(iterable: AsyncIterable[T], /, **attrs: Any) -> Optional[T]:
@overload
def get(iterable: AsyncIterable[T], /, **attrs: Any) -> Coro[Optional[T]]:
...
def get(iterable: AsyncIterable[T], /, **attrs: Any) -> Coro[Optional[T]]: ...
@overload
def get(iterable: Iterable[T], /, **attrs: Any) -> Optional[T]:
...
def get(iterable: Iterable[T], /, **attrs: Any) -> Optional[T]: ...
def get(iterable: _Iter[T], /, **attrs: Any) -> Union[Optional[T], Coro[Optional[T]]]:
@ -622,7 +610,7 @@ def _get_as_snowflake(data: Any, key: str) -> Optional[int]:
def _get_mime_type_for_image(data: bytes):
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
if data.startswith(b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a'):
return 'image/png'
elif data[0:3] == b'\xff\xd8\xff' or data[6:10] in (b'JFIF', b'Exif'):
return 'image/jpeg'
@ -756,13 +744,11 @@ def compute_timedelta(dt: datetime.datetime) -> float:
@overload
async def sleep_until(when: datetime.datetime, result: T) -> T:
...
async def sleep_until(when: datetime.datetime, result: T) -> T: ...
@overload
async def sleep_until(when: datetime.datetime) -> None:
...
async def sleep_until(when: datetime.datetime) -> None: ...
async def sleep_until(when: datetime.datetime, result: Optional[T] = None) -> Optional[T]:
@ -823,8 +809,7 @@ class SnowflakeList(_SnowflakeListBase):
if TYPE_CHECKING:
def __init__(self, data: Iterable[int], *, is_sorted: bool = False):
...
def __init__(self, data: Iterable[int], *, is_sorted: bool = False): ...
def __new__(cls, data: Iterable[int], *, is_sorted: bool = False) -> Self:
return array.array.__new__(cls, 'Q', data if is_sorted else sorted(data)) # type: ignore
@ -934,11 +919,11 @@ _MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format(
_MARKDOWN_ESCAPE_COMMON = r'^>(?:>>)?\s|\[.+\]\(.+\)|^#{1,3}|^\s*-'
_MARKDOWN_ESCAPE_REGEX = re.compile(fr'(?P<markdown>{_MARKDOWN_ESCAPE_SUBREGEX}|{_MARKDOWN_ESCAPE_COMMON})', re.MULTILINE)
_MARKDOWN_ESCAPE_REGEX = re.compile(rf'(?P<markdown>{_MARKDOWN_ESCAPE_SUBREGEX}|{_MARKDOWN_ESCAPE_COMMON})', re.MULTILINE)
_URL_REGEX = r'(?P<url><[^: >]+:\/[^ >]+>|(?:https?|steam):\/\/[^\s<]+[^<.,:;\"\'\]\s])'
_MARKDOWN_STOCK_REGEX = fr'(?P<markdown>[_\\~|\*`]|{_MARKDOWN_ESCAPE_COMMON})'
_MARKDOWN_STOCK_REGEX = rf'(?P<markdown>[_\\~|\*`]|{_MARKDOWN_ESCAPE_COMMON})'
def remove_markdown(text: str, *, ignore_links: bool = True) -> str:
@ -1073,13 +1058,11 @@ async def _achunk(iterator: AsyncIterable[T], max_size: int) -> AsyncIterator[Li
@overload
def as_chunks(iterator: AsyncIterable[T], max_size: int) -> AsyncIterator[List[T]]:
...
def as_chunks(iterator: AsyncIterable[T], max_size: int) -> AsyncIterator[List[T]]: ...
@overload
def as_chunks(iterator: Iterable[T], max_size: int) -> Iterator[List[T]]:
...
def as_chunks(iterator: Iterable[T], max_size: int) -> Iterator[List[T]]: ...
def as_chunks(iterator: _Iter[T], max_size: int) -> _Iter[List[T]]:
@ -1304,7 +1287,6 @@ def stream_supports_colour(stream: Any) -> bool:
class _ColourFormatter(logging.Formatter):
# ANSI codes are a bit weird to decipher if you're unfamiliar with them, so here's a refresher
# It starts off with a format like \x1b[XXXm where XXX is a semicolon separated list of commands
# The important ones here relate to colour.
@ -1499,37 +1481,37 @@ def _format_call_duration(duration: datetime.timedelta) -> str:
threshold_M = 10.5
if seconds < threshold_s:
formatted = "a few seconds"
formatted = 'a few seconds'
elif seconds < (threshold_m * minutes_s):
minutes = round(seconds / minutes_s)
if minutes == 1:
formatted = "a minute"
formatted = 'a minute'
else:
formatted = f"{minutes} minutes"
formatted = f'{minutes} minutes'
elif seconds < (threshold_h * hours_s):
hours = round(seconds / hours_s)
if hours == 1:
formatted = "an hour"
formatted = 'an hour'
else:
formatted = f"{hours} hours"
formatted = f'{hours} hours'
elif seconds < (threshold_d * days_s):
days = round(seconds / days_s)
if days == 1:
formatted = "a day"
formatted = 'a day'
else:
formatted = f"{days} days"
formatted = f'{days} days'
elif seconds < (threshold_M * months_s):
months = round(seconds / months_s)
if months == 1:
formatted = "a month"
formatted = 'a month'
else:
formatted = f"{months} months"
formatted = f'{months} months'
else:
years = round(seconds / years_s)
if years == 1:
formatted = "a year"
formatted = 'a year'
else:
formatted = f"{years} years"
formatted = f'{years} years'
return formatted