Skip to content

Commit e17f35f

Browse files
fix: Flake8 warnings and errors (#964)
* fix: take into account flake8 warnings, exclude line too long errors * ci: correct from checks. * added isort fixes * update examples/bot.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 826b9dd commit e17f35f

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

examples/bot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This code shows a very brief and small example of how to create a bot with our library.
22
# This example does not cover all the features of the library, but it is enough to get you started.
33
# In order to learn more about how to use the library, please head over to our documentation:
4-
# https://interactionspy.rtfd.io/en/latest/
4+
# https://interactionspy.readthedocs.io/en/latest/
55

66
# The first thing you need to do is import the library.
77
import interactions
@@ -12,6 +12,7 @@
1212
# The client is also the main object that interacts with the API, what makes requests with Discord.
1313
client = interactions.Client("your bot token will go here.")
1414

15+
1516
# With our client established, let's have the library inform us when the client is ready.
1617
# These are known as event listeners. An event listener can be established in one of two ways.
1718
# You can provide the name of the event, prefixed by an "on_", or by telling the event decorator what event it is.
@@ -64,7 +65,7 @@ async def hello_world(ctx: interactions.CommandContext):
6465

6566
# - we'll be syncing the commands automatically.
6667
# if you want to do this manually, you can do it by passing disable_sync=False in the Client
67-
# object on line 8.
68+
# object on line 13.
6869
# - we are not setting a presence.
6970
# - we are not automatically sharding, and registering the connection under 1 shard.
7071
# - we are using default intents, which are Gateway intents excluding privileged ones.

interactions/api/models/attrs_utils.pyi

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import wraps
2-
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, Type, overload
2+
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload
33

44
import attrs
55

@@ -67,13 +67,9 @@ def convert_dict(
6767
"""A helper function to convert the keys and values of a dictionary with the specified converters"""
6868

6969
@overload
70-
def deepcopy_kwargs() -> Callable[[_T], _T]:
71-
...
72-
70+
def deepcopy_kwargs() -> Callable[[_T], _T]: ...
7371
@overload
74-
def deepcopy_kwargs(cls: _T) -> _T:
75-
...
76-
72+
def deepcopy_kwargs(cls: _T) -> _T: ...
7773
def deepcopy_kwargs(cls: Optional[_T] = None) -> Union[Callable[[_T], _T], _T]:
7874
"""
7975
A decorator to make the DictSerializerMixin deepcopy the kwargs before processing them.

interactions/api/models/role.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def delete(
9090

9191
await self._client.delete_guild_role(
9292
guild_id=_guild_id, role_id=int(self.id), reason=reason
93-
),
93+
)
9494

9595
async def modify(
9696
self,
@@ -113,7 +113,7 @@ async def modify(
113113
:type name?: Optional[str]
114114
:param color?: RGB color value as integer, defaults to the current value of the role
115115
:type color?: Optional[int]
116-
:param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role
116+
:param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role
117117
:type permissions?: Optional[int]
118118
:param hoist?: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role
119119
:type hoist?: Optional[bool]

interactions/client/get.pyi

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from enum import Enum
22
from typing import Awaitable, Coroutine, List, Literal, Optional, Type, TypeVar, Union, overload
33

44
from interactions.client.bot import Client
5+
56
from ..api.http.client import HTTPClient
67
from ..api.models.channel import Channel
78
from ..api.models.guild import Guild
@@ -21,10 +22,10 @@ class Force(str, Enum):
2122
"""
2223
An enum representing the force methods for the get method
2324
"""
25+
2426
CACHE: str
2527
HTTP: str
2628

27-
2829
# API-object related
2930

3031
# with http force
@@ -35,17 +36,16 @@ def get(
3536
obj: Type[_SA],
3637
*,
3738
object_id: int,
38-
force: Optional[Literal["http", Force.HTTP]] = None
39+
force: Optional[Literal["http", Force.HTTP]] = None,
3940
) -> Awaitable[_SA]: ...
40-
4141
@overload
4242
def get(
4343
client: Client,
4444
obj: Type[_MA],
4545
*,
4646
parent_id: int,
4747
object_id: int,
48-
force: Optional[Literal["http", Force.HTTP]] = None
48+
force: Optional[Literal["http", Force.HTTP]] = None,
4949
) -> Awaitable[_MA]: ...
5050

5151
# list of objects
@@ -55,57 +55,65 @@ def get(
5555
obj: Type[List[_SA]],
5656
*,
5757
object_ids: List[int],
58-
force: Optional[Literal["http", Force.HTTP]] = None
58+
force: Optional[Literal["http", Force.HTTP]] = None,
5959
) -> Awaitable[List[_SA]]: ...
60-
6160
@overload
6261
def get(
6362
client: Client,
6463
obj: Type[List[_MA]],
6564
*,
6665
parent_id: int,
6766
object_ids: List[int],
68-
force: Optional[Literal["http", Force.HTTP]] = None
67+
force: Optional[Literal["http", Force.HTTP]] = None,
6968
) -> Awaitable[List[_MA]]: ...
7069

7170
# with cache force
7271
@overload
73-
def get(client: Client, obj: Type[_SA], *, object_id: int, force: Literal["cache", Force.CACHE]) -> Optional[_SA]: ...
74-
72+
def get(
73+
client: Client, obj: Type[_SA], *, object_id: int, force: Literal["cache", Force.CACHE]
74+
) -> Optional[_SA]: ...
7575
@overload
7676
def get(
77-
client: Client, obj: Type[_MA], *, parent_id: int, object_id: int, force: Literal["cache", Force.CACHE]
77+
client: Client,
78+
obj: Type[_MA],
79+
*,
80+
parent_id: int,
81+
object_id: int,
82+
force: Literal["cache", Force.CACHE],
7883
) -> Optional[_MA]: ...
7984

8085
# list of objects
8186
@overload
8287
def get(
83-
client: Client, obj: Type[List[_SA]], *, object_ids: List[int], force: Literal["cache", Force.CACHE]
88+
client: Client,
89+
obj: Type[List[_SA]],
90+
*,
91+
object_ids: List[int],
92+
force: Literal["cache", Force.CACHE],
8493
) -> List[Optional[_SA]]: ...
85-
8694
@overload
8795
def get(
8896
client: Client,
8997
obj: Type[List[_MA]],
9098
*,
9199
parent_id: int,
92100
object_ids: List[int],
93-
force: Literal["cache", Force.CACHE]
101+
force: Literal["cache", Force.CACHE],
94102
) -> List[Optional[_MA]]: ...
95103

96104
# Having a not-overloaded definition stops showing a warning/complaint from the IDE if wrong arguments are put in,
97105
# so we'll leave that out
98106

99107
def _get_cache(
100108
_object: Type[_T], client: Client, kwarg_name: str, _list: bool = False, **kwargs
101-
) -> Union[Optional[_T], List[Optional[_T]]]:...
109+
) -> Union[Optional[_T], List[Optional[_T]]]: ...
102110
async def _return_cache(
103111
obj: Union[Optional[_T], List[Optional[_T]]]
104-
) -> Union[Optional[_T], List[Optional[_T]]]:...
112+
) -> Union[Optional[_T], List[Optional[_T]]]: ...
105113
async def _http_request(
106114
obj: Type[_T],
107115
http: HTTPClient,
108116
request: Union[Coroutine, List[Union[_T, Coroutine]], List[Coroutine]] = None,
109117
_name: str = None,
110118
**kwargs,
111-
) -> Union[_T, List[_T]]:...
119+
) -> Union[_T, List[_T]]: ...

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
extend-ignore = E501

0 commit comments

Comments
 (0)