Skip to content

Commit 16773b0

Browse files
committed
Remove use of typing.final
1 parent f388e20 commit 16773b0

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ convention = "numpy"
9090
"typing.runtime_checkable".msg = "Runtime checkable is fundamentally unsafe."
9191
"typing_extensions.runtime_checkable".msg = "Runtime checkable is fundamentally unsafe."
9292

93+
# these don't work as deferred imports, intentionally, because type checkers are dumb
94+
# and require they be imported directly from typing to work, this breaks the deferred re-export.
95+
"typing.Final".msg = "see https://github.com/microsoft/pyright/issues/9664#issuecomment-2574042580"
96+
"typing_extensions.Final".msg = "see https://github.com/microsoft/pyright/issues/9664#issuecomment-2574042580"
97+
"typing.final".msg = "see https://github.com/microsoft/pyright/issues/9664#issuecomment-2574042580"
98+
"typing_extensions.final".msg = "see https://github.com/microsoft/pyright/issues/9664#issuecomment-2574042580"
99+
93100
[project]
94101
name = "async-utils"
95102
description = "Various async utilities"

src/async_utils/_paramkey.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from . import _typings as t
2424

2525

26-
@t.final
2726
class _HK:
2827
__slots__ = ("_hashvalue", "_tup")
2928

@@ -40,7 +39,7 @@ def __eq__(self, other: object) -> bool:
4039
return self._tup == other._tup
4140

4241

43-
_marker: t.Final[tuple[object]] = (object(),)
42+
_marker: tuple[object] = (object(),)
4443

4544

4645
def make_key(args: tuple[t.Any, ...], kwds: dict[t.Any, t.Any]) -> Hashable:

src/async_utils/_typings.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@
2929
TYPE_CHECKING = False
3030

3131
if TYPE_CHECKING:
32-
from typing import Any, Final, Literal, Self, final
33-
else:
34-
35-
def final(f): # noqa: ANN001
36-
return f
32+
from typing import Any, Literal, Self
3733

3834

3935
def __getattr__(name: str):
40-
if name in {"Any", "Final", "Literal", "Self"}:
36+
if name in {"Any", "Literal", "Self"}:
4137
import typing
4238

4339
return getattr(typing, name)
@@ -46,4 +42,4 @@ def __getattr__(name: str):
4642
raise AttributeError(msg)
4743

4844

49-
__all__ = ["Any", "Final", "Literal", "Self", "final"]
45+
__all__ = ["Any", "Literal", "Self"]

src/async_utils/sig_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
type HandleableSignals = t.Literal["SIGINT", "SIGTERM", "SIGBREAK", "SIGHUP"]
3535
type SignalTuple = tuple[HandleableSignals, ...]
3636

37-
default_handled: t.Final = "SIGINT", "SIGTERM", "SIGBREAK"
37+
default_handled: SignalTuple = "SIGINT", "SIGTERM", "SIGBREAK"
3838

3939

4040
class SpecialExit(enum.IntEnum):

0 commit comments

Comments
 (0)