Skip to content

Commit c9d20e7

Browse files
committed
Update typing of __new__ on SwgohComlinkBase
Updates return typing of __new__ to Self.
1 parent 28a2a9c commit c9d20e7

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
]
2424
dependencies = [
2525
"httpx>=0.28",
26+
"typing-extensions>=4.15.0; python_version < '3.11'",
2627
]
2728

2829
[project.scripts]

src/swgoh_comlink/_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@
1212
import time
1313
from collections.abc import Callable
1414
from json import dumps
15+
from sys import version_info
1516
from typing import Any
1617
from urllib.parse import urlparse, urlunparse
1718

1819
from .exceptions import SwgohComlinkValueError
1920
from .helpers import Constants
2021

22+
if version_info >= (3, 11):
23+
from typing import Self
24+
else:
25+
from typing_extensions import Self
26+
2127
__all__ = ["SwgohComlinkBase"]
2228

2329
# Keys whose values must be masked in logs, repr, and debug output.
@@ -92,11 +98,11 @@ def __repr__(self) -> str:
9298
f"secret_key={self._mask(self.secret_key)!r})"
9399
)
94100

95-
def __new__(cls, *args: Any, **kwargs: Any) -> SwgohComlinkBase:
101+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
96102
"""Prevent instances of this base class from being created directly."""
97103
if cls is SwgohComlinkBase:
98104
raise TypeError(f"Only subclasses of '{cls.__name__}' may be instantiated.")
99-
return object.__new__(cls)
105+
return super().__new__(cls)
100106

101107
def __init__(
102108
self,

0 commit comments

Comments
 (0)