Skip to content

Commit fcb9dc6

Browse files
authored
chore: move mutable class ref/attrs to ClassVar typing (#1497)
1 parent 579de0e commit fcb9dc6

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

interactions/client/const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import sys
4343
from collections import defaultdict
4444
from importlib.metadata import version as _v, PackageNotFoundError
45-
from typing import TypeVar, Union, Callable, Coroutine
45+
from typing import TypeVar, Union, Callable, Coroutine, ClassVar
4646

4747
__all__ = (
4848
"__version__",
@@ -131,7 +131,7 @@ def get_logger() -> logging.Logger:
131131

132132

133133
class Singleton(type):
134-
_instances = {}
134+
_instances: ClassVar[dict] = {}
135135

136136
def __call__(self, *args, **kwargs) -> "Singleton":
137137
if self not in self._instances:

interactions/client/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Any, TYPE_CHECKING, Callable, Coroutine, List, Optional, SupportsInt, Union
1+
from typing import Dict, Any, TYPE_CHECKING, Callable, Coroutine, ClassVar, List, Optional, SupportsInt, Union
22

33
import aiohttp
44

@@ -201,7 +201,7 @@ class WebSocketClosed(LibraryException):
201201
"""The websocket was closed."""
202202

203203
code: int = 0
204-
codes: Dict[int, str] = {
204+
codes: ClassVar[Dict[int, str]] = {
205205
1000: "Normal Closure",
206206
4000: "Unknown Error",
207207
4001: "Unknown OpCode",
@@ -228,7 +228,7 @@ class VoiceWebSocketClosed(LibraryException):
228228
"""The voice websocket was closed."""
229229

230230
code: int = 0
231-
codes: Dict[int, str] = {
231+
codes: ClassVar[Dict[int, str]] = {
232232
1000: "Normal Closure",
233233
4000: "Unknown Error",
234234
4001: "Unknown OpCode",

interactions/ext/debug_extension/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import platform
33
import tracemalloc
4+
from typing import ClassVar
45

56
from interactions import (
67
Client,
@@ -28,7 +29,7 @@ class Metadata(Extension.Metadata):
2829
description = "Debugging utilities for interactions.py"
2930
version = "1.0.0"
3031
url = "https://github.com/interactions-py/interactions.py"
31-
requirements = ["interactions>=5.0.0"]
32+
requirements: ClassVar[list] = ["interactions>=5.0.0"]
3233

3334
def __init__(self, bot: Client) -> None:
3435
bot.logger.info("Debug Extension is mounting!")

0 commit comments

Comments
 (0)