Skip to content

Commit 7f3eab4

Browse files
authored
Fix python <3.11 compat. fix #5 (#6)
1 parent afcf381 commit 7f3eab4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/datastar_py/attributes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import re
55
from collections.abc import Iterable, Iterator, Mapping
66
from itertools import chain
7-
from typing import Literal, Self, TypeAlias, TypeVar, Union, overload
7+
from typing import TYPE_CHECKING, Literal, TypeAlias, Union, overload
8+
9+
if TYPE_CHECKING:
10+
from typing import Self
811

912
__all__ = ["attribute_generator"]
1013

@@ -379,17 +382,14 @@ def __str__(self) -> str:
379382
__html__ = __str__
380383

381384

382-
TAttr = TypeVar("TAttr", bound=BaseAttr)
383-
384-
385385
class TimingMod:
386386
def debounce(
387-
self: TAttr,
387+
self: Self,
388388
wait: int | float | str,
389389
*,
390390
leading: bool = False,
391391
notrail: bool = False,
392-
) -> TAttr:
392+
) -> Self:
393393
"""Debounce the event listener.
394394
395395
:param wait: The minimum interval between events.
@@ -406,12 +406,12 @@ def debounce(
406406
return self
407407

408408
def throttle(
409-
self: TAttr,
409+
self: Self,
410410
wait: int | float | str,
411411
*,
412412
noleading: bool = False,
413413
trail: bool = False,
414-
) -> TAttr:
414+
) -> Self:
415415
"""Throttle the event listener.
416416
417417
:param wait: The minimum interval between events.
@@ -430,7 +430,7 @@ def throttle(
430430

431431
class ViewtransitionMod:
432432
@property
433-
def viewtransition(self: TAttr) -> TAttr:
433+
def viewtransition(self: Self) -> Self:
434434
"""Wrap the expression in document.startViewTransition()."""
435435
self._mods["view-transition"] = []
436436
return self

0 commit comments

Comments
 (0)