Skip to content

Commit fc439fb

Browse files
authored
Merge pull request #94 from bckohan/v2.x.x
fix #93, remove pylint pragmas
2 parents 677d4a2 + d00b8c1 commit fc439fb

File tree

4 files changed

+42
-39
lines changed

4 files changed

+42
-39
lines changed

django_typer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
model_parser_completer, # noqa: F401
4848
)
4949

50-
VERSION = (2, 1, 1)
50+
VERSION = (2, 1, 2)
5151

5252
__title__ = "Django Typer"
5353
__version__ = ".".join(str(i) for i in VERSION)

django_typer/management/__init__.py

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def get_command( # type: ignore[overload-overlap]
179179
stderr: t.Optional[t.IO[str]] = None,
180180
no_color: bool = False,
181181
force_color: bool = False,
182-
**kwargs,
182+
**kwargs: t.Any,
183183
) -> BaseCommand: ...
184184

185185

@@ -192,7 +192,7 @@ def get_command(
192192
stderr: t.Optional[t.IO[str]] = None,
193193
no_color: bool = False,
194194
force_color: bool = False,
195-
**kwargs,
195+
**kwargs: t.Any,
196196
) -> C: ...
197197

198198

@@ -205,7 +205,7 @@ def get_command(
205205
stderr: t.Optional[t.IO[str]] = None,
206206
no_color: bool = False,
207207
force_color: bool = False,
208-
**kwargs,
208+
**kwargs: t.Any,
209209
) -> MethodType: ...
210210

211211

@@ -216,7 +216,7 @@ def get_command(
216216
stderr=None,
217217
no_color: bool = False,
218218
force_color: bool = False,
219-
**kwargs,
219+
**kwargs: t.Any,
220220
):
221221
"""
222222
Get a Django_ command by its name and instantiate it with the provided options. This
@@ -335,13 +335,13 @@ def _get_common_params() -> t.Sequence[t.Union[click.Argument, click.Option]]:
335335
}
336336

337337

338-
class _ParsedArgs(SimpleNamespace): # pylint: disable=too-few-public-methods
338+
class _ParsedArgs(SimpleNamespace):
339339
"""
340340
Emulate the argparse.Namespace class so that we can pass the parsed arguments
341341
into the BaseCommand infrastructure in the way it expects.
342342
"""
343343

344-
def __init__(self, args: t.Sequence[t.Any], **kwargs):
344+
def __init__(self, args: t.Sequence[t.Any], **kwargs: t.Any):
345345
super().__init__(**kwargs)
346346
self.args = args
347347
self.traceback = kwargs.get("traceback", TyperCommand._traceback)
@@ -393,11 +393,11 @@ def supplied_params(self) -> t.Dict[str, t.Any]:
393393

394394
def __init__(
395395
self,
396-
command: click.Command, # pylint: disable=redefined-outer-name
396+
command: click.Command,
397397
parent: t.Optional["Context"] = None,
398398
django_command: t.Optional["TyperCommand"] = None,
399399
supplied_params: t.Optional[t.Dict[str, t.Any]] = None,
400-
**kwargs,
400+
**kwargs: t.Any,
401401
):
402402
super().__init__(command, parent=parent, **kwargs)
403403
if supplied_params:
@@ -518,7 +518,7 @@ def __init__(
518518
*args,
519519
callback: t.Optional[t.Callable[..., t.Any]],
520520
params: t.Optional[t.List[click.Parameter]] = None,
521-
**kwargs,
521+
**kwargs: t.Any,
522522
):
523523
params = params or []
524524
self._callback = callback
@@ -655,7 +655,7 @@ def _cache_initializer(
655655
name: t.Optional[str] = Default(None),
656656
help: t.Optional[t.Union[str, Promise]] = Default(None),
657657
cls: t.Type[DTGroup] = DTGroup,
658-
**kwargs,
658+
**kwargs: t.Any,
659659
):
660660
def register(
661661
cmd: "TyperCommand",
@@ -683,7 +683,7 @@ def _cache_command(
683683
name: t.Optional[str] = None,
684684
help: t.Optional[t.Union[str, Promise]] = None,
685685
cls: t.Type[DTCommand] = DTCommand,
686-
**kwargs,
686+
**kwargs: t.Any,
687687
):
688688
def register(
689689
cmd: "TyperCommand",
@@ -737,7 +737,7 @@ class AppFactory(type):
737737
the Typer-like functional interface is used.
738738
"""
739739

740-
def __call__(self, *args, **kwargs) -> "Typer":
740+
def __call__(self, *args, **kwargs: t.Any) -> "Typer":
741741
if called_from_module():
742742
frame = inspect.currentframe()
743743
cmd_module = inspect.getmodule(frame.f_back) if frame else None
@@ -901,7 +901,7 @@ def __init__(
901901
pretty_exceptions_short: bool = True,
902902
parent: t.Optional["Typer"] = None,
903903
django_command: t.Optional[t.Type["TyperCommand"]] = None,
904-
**kwargs,
904+
**kwargs: t.Any,
905905
):
906906
assert not args # should have been removed by metaclass
907907
self.parent = parent
@@ -974,7 +974,7 @@ def callback( # type: ignore
974974
deprecated: bool = Default(False),
975975
# Rich settings
976976
rich_help_panel: t.Union[str, None] = Default(None),
977-
**kwargs,
977+
**kwargs: t.Any,
978978
) -> t.Callable[
979979
[typer.models.CommandFunctionType], typer.models.CommandFunctionType
980980
]:
@@ -1032,7 +1032,7 @@ def command( # type: ignore
10321032
deprecated: bool = False,
10331033
# Rich settings
10341034
rich_help_panel: t.Union[str, None] = Default(None),
1035-
**kwargs,
1035+
**kwargs: t.Any,
10361036
) -> t.Callable[[t.Callable[P2, R2]], t.Callable[P2, R2]]:
10371037
"""
10381038
A function decorator that creates a new command and attaches it to this group.
@@ -1082,9 +1082,7 @@ def command1(self):
10821082

10831083
def make_command(func: t.Callable[P2, R2]) -> t.Callable[P2, R2]:
10841084
return _check_static(
1085-
super( # pylint: disable=super-with-arguments
1086-
Typer, self
1087-
).command(
1085+
super(Typer, self).command(
10881086
name=name,
10891087
cls=type(
10901088
"_Command", (cls,), {"django_command": self.django_command}
@@ -1128,7 +1126,7 @@ def add_typer( # type: ignore
11281126
deprecated: bool = Default(False),
11291127
# Rich settings
11301128
rich_help_panel: t.Union[str, None] = Default(None),
1131-
**kwargs,
1129+
**kwargs: t.Any,
11321130
) -> None:
11331131
typer_instance.parent = self
11341132
typer_instance.django_command = self.django_command
@@ -1166,7 +1164,7 @@ def group(
11661164
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
11671165
# Command
11681166
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
1169-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
1167+
help: t.Optional[t.Union[str, Promise]] = Default(None),
11701168
epilog: t.Optional[str] = Default(None),
11711169
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
11721170
options_metavar: str = Default("[OPTIONS]"),
@@ -1175,7 +1173,7 @@ def group(
11751173
deprecated: bool = Default(False),
11761174
# Rich settings
11771175
rich_help_panel: t.Union[str, None] = Default(None),
1178-
**kwargs,
1176+
**kwargs: t.Any,
11791177
) -> t.Callable[[t.Callable[P2, R2]], "Typer[P2, R2]"]:
11801178
"""
11811179
Create a new subgroup and attach it to this group. This is like creating a new
@@ -1304,7 +1302,7 @@ def initialize(
13041302
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
13051303
# Command
13061304
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
1307-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
1305+
help: t.Optional[t.Union[str, Promise]] = Default(None),
13081306
epilog: t.Optional[str] = Default(None),
13091307
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
13101308
options_metavar: str = Default("[OPTIONS]"),
@@ -1313,7 +1311,7 @@ def initialize(
13131311
deprecated: bool = Default(False),
13141312
# Rich settings
13151313
rich_help_panel: t.Union[str, None] = Default(None),
1316-
**kwargs,
1314+
**kwargs: t.Any,
13171315
) -> t.Callable[[t.Callable[P2, R2]], t.Callable[P2, R2]]:
13181316
"""
13191317
A function decorator that creates a Typer_
@@ -1438,12 +1436,12 @@ def make_initializer(func: t.Callable[P2, R2]) -> t.Callable[P2, R2]:
14381436
callback = initialize # allow callback as an alias
14391437

14401438

1441-
def command( # pylint: disable=keyword-arg-before-vararg
1439+
def command(
14421440
name: t.Optional[str] = None,
14431441
*,
14441442
cls: t.Type[DTCommand] = DTCommand,
14451443
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = None,
1446-
help: t.Optional[t.Union[str, Promise]] = None, # pylint: disable=redefined-builtin
1444+
help: t.Optional[t.Union[str, Promise]] = None,
14471445
epilog: t.Optional[str] = None,
14481446
short_help: t.Optional[t.Union[str, Promise]] = None,
14491447
options_metavar: str = "[OPTIONS]",
@@ -1453,7 +1451,7 @@ def command( # pylint: disable=keyword-arg-before-vararg
14531451
deprecated: bool = False,
14541452
# Rich settings
14551453
rich_help_panel: t.Union[str, None] = Default(None),
1456-
**kwargs,
1454+
**kwargs: t.Any,
14571455
) -> t.Callable[[t.Callable[P, R]], t.Callable[P, R]]:
14581456
"""
14591457
A function decorator that creates a new command and attaches it to the root
@@ -1545,7 +1543,7 @@ def group(
15451543
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
15461544
# Command
15471545
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
1548-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
1546+
help: t.Optional[t.Union[str, Promise]] = Default(None),
15491547
epilog: t.Optional[str] = Default(None),
15501548
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
15511549
options_metavar: str = Default("[OPTIONS]"),
@@ -1554,7 +1552,7 @@ def group(
15541552
deprecated: bool = Default(False),
15551553
# Rich settings
15561554
rich_help_panel: t.Union[str, None] = Default(None),
1557-
**kwargs,
1555+
**kwargs: t.Any,
15581556
) -> t.Callable[[t.Callable[P, R]], Typer[P, R]]:
15591557
"""
15601558
A function decorator that creates a new subgroup and attaches it to the root
@@ -1869,7 +1867,7 @@ def __new__(
18691867
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
18701868
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
18711869
callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
1872-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
1870+
help: t.Optional[t.Union[str, Promise]] = Default(None),
18731871
epilog: t.Optional[str] = Default(None),
18741872
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
18751873
options_metavar: str = Default("[OPTIONS]"),
@@ -1883,7 +1881,7 @@ def __new__(
18831881
True
18841882
),
18851883
pretty_exceptions_short: t.Union[DefaultPlaceholder, bool] = Default(True),
1886-
**kwargs,
1884+
**kwargs: t.Any,
18871885
):
18881886
"""
18891887
This method is called when a new class is created.
@@ -2489,7 +2487,7 @@ def initialize(
24892487
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
24902488
# Command
24912489
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
2492-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
2490+
help: t.Optional[t.Union[str, Promise]] = Default(None),
24932491
epilog: t.Optional[str] = Default(None),
24942492
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
24952493
options_metavar: str = Default("[OPTIONS]"),
@@ -2498,7 +2496,7 @@ def initialize(
24982496
deprecated: bool = Default(False),
24992497
# Rich settings
25002498
rich_help_panel: t.Union[str, None] = Default(None),
2501-
**kwargs,
2499+
**kwargs: t.Any,
25022500
) -> t.Callable[[t.Callable[P, R]], t.Callable[P, R]]:
25032501
"""
25042502
Override the initializer for this command class after it has been defined.
@@ -2598,7 +2596,7 @@ def command(
25982596
*,
25992597
cls: t.Type[DTCommand] = DTCommand,
26002598
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = None,
2601-
help: t.Optional[t.Union[str, Promise]] = None, # pylint: disable=redefined-builtin
2599+
help: t.Optional[t.Union[str, Promise]] = None,
26022600
epilog: t.Optional[str] = None,
26032601
short_help: t.Optional[t.Union[str, Promise]] = None,
26042602
options_metavar: str = "[OPTIONS]",
@@ -2608,7 +2606,7 @@ def command(
26082606
deprecated: bool = False,
26092607
# Rich settings
26102608
rich_help_panel: t.Union[str, None] = Default(None),
2611-
**kwargs,
2609+
**kwargs: t.Any,
26122610
) -> t.Callable[[t.Callable[P, R]], t.Callable[P, R]]:
26132611
"""
26142612
Add a command to this command class after it has been defined. You can
@@ -2697,7 +2695,7 @@ def group(
26972695
result_callback: t.Optional[t.Callable[..., t.Any]] = Default(None),
26982696
# Command
26992697
context_settings: t.Optional[t.Dict[t.Any, t.Any]] = Default(None),
2700-
help: t.Optional[t.Union[str, Promise]] = Default(None), # pylint: disable=redefined-builtin
2698+
help: t.Optional[t.Union[str, Promise]] = Default(None),
27012699
epilog: t.Optional[str] = Default(None),
27022700
short_help: t.Optional[t.Union[str, Promise]] = Default(None),
27032701
options_metavar: str = Default("[OPTIONS]"),
@@ -2706,7 +2704,7 @@ def group(
27062704
deprecated: bool = Default(False),
27072705
# Rich settings
27082706
rich_help_panel: t.Union[str, None] = Default(None),
2709-
**kwargs,
2707+
**kwargs: t.Any,
27102708
) -> t.Callable[[t.Callable[P, R]], Typer[P, R]]:
27112709
"""
27122710
Add a group to this command class after it has been defined. You can
@@ -2853,7 +2851,7 @@ def __init__(
28532851
stderr: t.Optional[t.TextIO] = None,
28542852
no_color: bool = no_color,
28552853
force_color: bool = force_color,
2856-
**kwargs,
2854+
**kwargs: t.Any,
28572855
):
28582856
assert self.typer_app.info.name
28592857
_load_command_plugins(self.typer_app.info.name)

doc/source/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Change Log
33
==========
44

5+
v2.1.2
6+
======
7+
8+
* Fixed `Type hint kwargs to silence pylance warnings about partially unknown types <https://github.com/bckohan/django-typer/issues/93>`_
9+
510
v2.1.1
611
======
712

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-typer"
3-
version = "2.1.1"
3+
version = "2.1.2"
44
description = "Use Typer to define the CLI for your Django management commands."
55
authors = ["Brian Kohan <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)