Skip to content

Commit f2736fb

Browse files
committed
remove dead python < 3.9 code #247
1 parent 461f7ff commit f2736fb

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

src/django_typer/management/__init__.py

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@
5555
with_typehint,
5656
)
5757

58-
if sys.version_info < (3, 10):
59-
from typing_extensions import Concatenate, ParamSpec
60-
else:
61-
from typing import Concatenate, ParamSpec
62-
63-
6458
DEFAULT_MARKUP_MODE = getattr(typer.core, "DEFAULT_MARKUP_MODE", None)
6559

6660

@@ -81,8 +75,8 @@
8175
"get_command",
8276
]
8377

84-
P = ParamSpec("P")
85-
P2 = ParamSpec("P2")
78+
P = t.ParamSpec("P")
79+
P2 = t.ParamSpec("P2")
8680
R = t.TypeVar("R")
8781
R2 = t.TypeVar("R2")
8882
C = t.TypeVar("C", bound=BaseCommand)
@@ -91,28 +85,6 @@
9185
_CACHE_KEY = "_register_typer"
9286

9387

94-
if sys.version_info < (3, 10):
95-
# todo - remove this when support for <3.10 is dropped
96-
class static_factory(type):
97-
def __call__(self, *args, **kwargs):
98-
assert args
99-
if type(args[0]).__name__ == "staticmethod":
100-
return args[0]
101-
return super().__call__(*args, **kwargs)
102-
103-
class staticmethod(t.Generic[P, R], metaclass=static_factory):
104-
__func__: t.Callable[P, R]
105-
106-
def __init__(self, func: t.Callable[P, R]):
107-
self.__func__ = func
108-
109-
def __getattr__(self, name):
110-
return getattr(self.__func__, name)
111-
112-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
113-
return self.__func__(*args, **kwargs)
114-
115-
11688
@t.overload # pragma: no cover
11789
def get_command(
11890
command_name: str,
@@ -940,7 +912,7 @@ def __init__(
940912
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
941913
# Command
942914
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
943-
callback: t.Optional[t.Callable[Concatenate[TC, P], R]] = Default(None),
915+
callback: t.Optional[t.Callable[t.Concatenate[TC, P], R]] = Default(None),
944916
help: t.Optional[t.Union[str, Promise]] = Default(None),
945917
epilog: t.Optional[str] = Default(None),
946918
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
@@ -1246,7 +1218,7 @@ def group(
12461218
) -> t.Callable[
12471219
[
12481220
t.Callable[
1249-
Concatenate[TC, P2], R2 # pyright: ignore[reportInvalidTypeVarUse]
1221+
t.Concatenate[TC, P2], R2 # pyright: ignore[reportInvalidTypeVarUse]
12501222
]
12511223
],
12521224
"Typer[P2, R2]",
@@ -1299,7 +1271,7 @@ def subcommand(self):
12991271
"""
13001272

13011273
def create_app(
1302-
func: t.Callable[Concatenate[TC, P2], R2],
1274+
func: t.Callable[t.Concatenate[TC, P2], R2],
13031275
) -> Typer[P2, R2]:
13041276
grp: Typer[P2, R2] = Typer( # pyright: ignore[reportAssignmentType]
13051277
name=name or _strip_static(func).__name__.replace("_", "-"),
@@ -1697,7 +1669,7 @@ def group(
16971669
rich_help_panel: t.Union[str, None] = Default(None),
16981670
**kwargs: t.Any,
16991671
) -> t.Callable[
1700-
[t.Callable[Concatenate[TC, P], R]], # pyright: ignore[reportInvalidTypeVarUse]
1672+
[t.Callable[t.Concatenate[TC, P], R]], # pyright: ignore[reportInvalidTypeVarUse]
17011673
Typer[P, R],
17021674
]:
17031675
"""
@@ -1766,7 +1738,7 @@ def subcommand(self):
17661738
"""
17671739

17681740
def create_app(
1769-
func: t.Callable[Concatenate[TC, P], R],
1741+
func: t.Callable[t.Concatenate[TC, P], R],
17701742
) -> Typer[P, R]:
17711743
grp = Typer(
17721744
name=name or _strip_static(func).__name__.replace("_", "-"),
@@ -2951,7 +2923,7 @@ def group(
29512923
) -> t.Callable[
29522924
[
29532925
t.Callable[
2954-
Concatenate[TC, P], R # pyright: ignore[reportInvalidTypeVarUse]
2926+
t.Concatenate[TC, P], R # pyright: ignore[reportInvalidTypeVarUse]
29552927
]
29562928
],
29572929
Typer[P, R],
@@ -3023,7 +2995,7 @@ def grp_command(self, ...):
30232995
)
30242996

30252997
def create_app(
3026-
func: t.Callable[Concatenate[TC, P], R],
2998+
func: t.Callable[t.Concatenate[TC, P], R],
30272999
) -> Typer[P, R]:
30283000
grp: Typer[P, R] = Typer(
30293001
name=name or func.__name__.replace("_", "-"),

0 commit comments

Comments
 (0)