Skip to content

Commit dea2f56

Browse files
committed
Merge remote-tracking branch 'upstream/master' into akiko
2 parents e6bffc7 + 9dbf13c commit dea2f56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1796
-959
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install dependencies
2828
id: install-deps
2929
run: |
30-
python -m pip install --upgrade pip setuptools wheel black==22.6 requests
30+
python -m pip install --upgrade pip setuptools wheel ruff==0.12 requests
3131
pip install -U -r requirements.txt
3232
3333
- name: Setup node.js
@@ -42,7 +42,7 @@ jobs:
4242
warnings: false
4343
no-comments: ${{ matrix.python-version != '3.x' }}
4444

45-
- name: Run black
45+
- name: Run ruff
4646
if: ${{ always() && steps.install-deps.outcome == 'success' }}
4747
run: |
48-
black --check discord examples
48+
ruff format --check discord examples

discord/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__author__ = 'Rapptz'
1414
__license__ = 'MIT'
1515
__copyright__ = 'Copyright 2015-present Rapptz'
16-
__version__ = '2.6.0a'
16+
__version__ = '2.7.0a'
1717

1818
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1919

@@ -81,11 +81,11 @@ class VersionInfo(NamedTuple):
8181
major: int
8282
minor: int
8383
micro: int
84-
releaselevel: Literal["alpha", "beta", "candidate", "final"]
84+
releaselevel: Literal['alpha', 'beta', 'candidate', 'final']
8585
serial: int
8686

8787

88-
version_info: VersionInfo = VersionInfo(major=2, minor=6, micro=0, releaselevel='alpha', serial=0)
88+
version_info: VersionInfo = VersionInfo(major=2, minor=7, micro=0, releaselevel='alpha', serial=0)
8989

9090
logging.getLogger(__name__).addHandler(logging.NullHandler())
9191

discord/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def setup(bot):
133133
await bot.add_cog({name}(bot))
134134
'''
135135

136-
_cog_extras = '''
136+
_cog_extras = """
137137
async def cog_load(self):
138138
# loading logic goes here
139139
pass
@@ -170,7 +170,7 @@ async def cog_after_invoke(self, ctx):
170170
# called after a command is called here
171171
pass
172172
173-
'''
173+
"""
174174

175175

176176
# certain file names and directory names are forbidden

discord/abc.py

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
T = TypeVar('T', bound=VoiceProtocol)
7878

7979
if TYPE_CHECKING:
80-
from typing_extensions import Self
80+
from typing_extensions import Self, Unpack
8181

8282
from .client import Client
8383
from .user import ClientUser
@@ -112,10 +112,11 @@
112112
from .types.snowflake import (
113113
SnowflakeList,
114114
)
115+
from .permissions import _PermissionOverwriteKwargs
115116

116117
PartialMessageableChannel = Union[TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, PartialMessageable]
117118
MessageableChannel = Union[PartialMessageableChannel, GroupChannel]
118-
SnowflakeTime = Union["Snowflake", datetime]
119+
SnowflakeTime = Union['Snowflake', datetime]
119120

120121
class PinnedMessage(Message):
121122
pinned_at: datetime
@@ -139,7 +140,7 @@ def __init__(self, iterator: AsyncIterator[PinnedMessage]) -> None:
139140

140141
def __await__(self) -> Generator[Any, None, List[PinnedMessage]]:
141142
warnings.warn(
142-
"`await <channel>.pins()` is deprecated; use `async for message in <channel>.pins()` instead.",
143+
'`await <channel>.pins()` is deprecated; use `async for message in <channel>.pins()` instead.',
143144
DeprecationWarning,
144145
stacklevel=2,
145146
)
@@ -422,8 +423,7 @@ class GuildChannel:
422423

423424
if TYPE_CHECKING:
424425

425-
def __init__(self, *, state: ConnectionState, guild: Guild, data: GuildChannelPayload):
426-
...
426+
def __init__(self, *, state: ConnectionState, guild: Guild, data: GuildChannelPayload): ...
427427

428428
def __str__(self) -> str:
429429
return self.name
@@ -793,7 +793,6 @@ def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
793793

794794
default = self.guild.default_role
795795
if default is None:
796-
797796
if self._state.self_id == obj.id:
798797
return Permissions._user_installed_permissions(in_guild=True)
799798
else:
@@ -906,26 +905,24 @@ async def set_permissions(
906905
*,
907906
overwrite: Optional[Union[PermissionOverwrite, _Undefined]] = ...,
908907
reason: Optional[str] = ...,
909-
) -> None:
910-
...
908+
) -> None: ...
911909

912910
@overload
913911
async def set_permissions(
914912
self,
915913
target: Union[Member, Role],
916914
*,
917915
reason: Optional[str] = ...,
918-
**permissions: Optional[bool],
919-
) -> None:
920-
...
916+
**permissions: Unpack[_PermissionOverwriteKwargs],
917+
) -> None: ...
921918

922919
async def set_permissions(
923920
self,
924921
target: Union[Member, Role],
925922
*,
926923
overwrite: Any = _undefined,
927924
reason: Optional[str] = None,
928-
**permissions: Optional[bool],
925+
**permissions: Unpack[_PermissionOverwriteKwargs],
929926
) -> None:
930927
r"""|coro|
931928
@@ -1108,8 +1105,7 @@ async def move(
11081105
category: Optional[Snowflake] = MISSING,
11091106
sync_permissions: bool = MISSING,
11101107
reason: Optional[str] = MISSING,
1111-
) -> None:
1112-
...
1108+
) -> None: ...
11131109

11141110
@overload
11151111
async def move(
@@ -1120,8 +1116,7 @@ async def move(
11201116
category: Optional[Snowflake] = MISSING,
11211117
sync_permissions: bool = MISSING,
11221118
reason: str = MISSING,
1123-
) -> None:
1124-
...
1119+
) -> None: ...
11251120

11261121
@overload
11271122
async def move(
@@ -1132,8 +1127,7 @@ async def move(
11321127
category: Optional[Snowflake] = MISSING,
11331128
sync_permissions: bool = MISSING,
11341129
reason: str = MISSING,
1135-
) -> None:
1136-
...
1130+
) -> None: ...
11371131

11381132
@overload
11391133
async def move(
@@ -1144,8 +1138,7 @@ async def move(
11441138
category: Optional[Snowflake] = MISSING,
11451139
sync_permissions: bool = MISSING,
11461140
reason: str = MISSING,
1147-
) -> None:
1148-
...
1141+
) -> None: ...
11491142

11501143
async def move(self, **kwargs: Any) -> None:
11511144
"""|coro|
@@ -1427,8 +1420,7 @@ async def send(
14271420
view: LayoutView,
14281421
suppress_embeds: bool = ...,
14291422
silent: bool = ...,
1430-
) -> Message:
1431-
...
1423+
) -> Message: ...
14321424

14331425
@overload
14341426
async def send(
@@ -1443,8 +1435,7 @@ async def send(
14431435
view: LayoutView,
14441436
suppress_embeds: bool = ...,
14451437
silent: bool = ...,
1446-
) -> Message:
1447-
...
1438+
) -> Message: ...
14481439

14491440
@overload
14501441
async def send(
@@ -1464,8 +1455,7 @@ async def send(
14641455
suppress_embeds: bool = ...,
14651456
silent: bool = ...,
14661457
poll: Poll = ...,
1467-
) -> Message:
1468-
...
1458+
) -> Message: ...
14691459

14701460
@overload
14711461
async def send(
@@ -1485,8 +1475,7 @@ async def send(
14851475
suppress_embeds: bool = ...,
14861476
silent: bool = ...,
14871477
poll: Poll = ...,
1488-
) -> Message:
1489-
...
1478+
) -> Message: ...
14901479

14911480
@overload
14921481
async def send(
@@ -1506,8 +1495,7 @@ async def send(
15061495
suppress_embeds: bool = ...,
15071496
silent: bool = ...,
15081497
poll: Poll = ...,
1509-
) -> Message:
1510-
...
1498+
) -> Message: ...
15111499

15121500
@overload
15131501
async def send(
@@ -1527,8 +1515,7 @@ async def send(
15271515
suppress_embeds: bool = ...,
15281516
silent: bool = ...,
15291517
poll: Poll = ...,
1530-
) -> Message:
1531-
...
1518+
) -> Message: ...
15321519

15331520
async def send(
15341521
self,
@@ -2030,7 +2017,7 @@ async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Op
20302017
if limit is None:
20312018
raise ValueError('history does not support around with limit=None')
20322019
if limit > 101:
2033-
raise ValueError("history max limit 101 when specifying around parameter")
2020+
raise ValueError('history max limit 101 when specifying around parameter')
20342021

20352022
# Strange Discord quirk
20362023
limit = 100 if limit == 101 else limit

discord/activity.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,11 @@ def __repr__(self) -> str:
861861

862862

863863
@overload
864-
def create_activity(data: ActivityPayload, state: ConnectionState) -> ActivityTypes:
865-
...
864+
def create_activity(data: ActivityPayload, state: ConnectionState) -> ActivityTypes: ...
866865

867866

868867
@overload
869-
def create_activity(data: None, state: ConnectionState) -> None:
870-
...
868+
def create_activity(data: None, state: ConnectionState) -> None: ...
871869

872870

873871
def create_activity(data: Optional[ActivityPayload], state: ConnectionState) -> Optional[ActivityTypes]:

discord/app_commands/checks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
T = TypeVar('T')
5656

5757
if TYPE_CHECKING:
58-
from typing_extensions import Self
58+
from typing_extensions import Self, Unpack
5959
from ..interactions import Interaction
60+
from ..permissions import _PermissionsKwargs
6061

6162
CooldownFunction = Union[
6263
Callable[[Interaction[Any]], Coroutine[Any, Any, T]],
@@ -286,7 +287,7 @@ def predicate(interaction: Interaction) -> bool:
286287
return check(predicate)
287288

288289

289-
def has_permissions(**perms: bool) -> Callable[[T], T]:
290+
def has_permissions(**perms: Unpack[_PermissionsKwargs]) -> Callable[[T], T]:
290291
r"""A :func:`~discord.app_commands.check` that is added that checks if the member
291292
has all of the permissions necessary.
292293
@@ -326,7 +327,7 @@ async def test(interaction: discord.Interaction):
326327

327328
invalid = perms.keys() - Permissions.VALID_FLAGS.keys()
328329
if invalid:
329-
raise TypeError(f"Invalid permission(s): {', '.join(invalid)}")
330+
raise TypeError(f'Invalid permission(s): {", ".join(invalid)}')
330331

331332
def predicate(interaction: Interaction) -> bool:
332333
permissions = interaction.permissions
@@ -341,7 +342,7 @@ def predicate(interaction: Interaction) -> bool:
341342
return check(predicate)
342343

343344

344-
def bot_has_permissions(**perms: bool) -> Callable[[T], T]:
345+
def bot_has_permissions(**perms: Unpack[_PermissionsKwargs]) -> Callable[[T], T]:
345346
"""Similar to :func:`has_permissions` except checks if the bot itself has
346347
the permissions listed. This relies on :attr:`discord.Interaction.app_permissions`.
347348
@@ -353,7 +354,7 @@ def bot_has_permissions(**perms: bool) -> Callable[[T], T]:
353354

354355
invalid = set(perms) - set(Permissions.VALID_FLAGS)
355356
if invalid:
356-
raise TypeError(f"Invalid permission(s): {', '.join(invalid)}")
357+
raise TypeError(f'Invalid permission(s): {", ".join(invalid)}')
357358

358359
def predicate(interaction: Interaction) -> bool:
359360
permissions = interaction.app_permissions
@@ -370,7 +371,6 @@ def predicate(interaction: Interaction) -> bool:
370371
def _create_cooldown_decorator(
371372
key: CooldownFunction[Hashable], factory: CooldownFunction[Optional[Cooldown]]
372373
) -> Callable[[T], T]:
373-
374374
mapping: Dict[Any, Cooldown] = {}
375375

376376
async def get_bucket(

0 commit comments

Comments
 (0)