Skip to content

Commit

Permalink
make name property private #37
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Mar 5, 2024
1 parent 48d42ea commit cdbefaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ def command2(self, option: t.Optional[str] = None):
command_tree: CommandNode

@property
def name(self) -> str:
def _name(self) -> str:
"""The name of the django command"""
return self.typer_app.info.name or self.__module__.rsplit(".", maxsplit=1)[-1]

Expand Down Expand Up @@ -1715,7 +1715,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
getattr(self, "_called_from_command_line", False)
and not self._traceback
):
self.print_help(sys.argv[0], self.name, *cmd_pth)
self.print_help(sys.argv[0], self._name, *cmd_pth)
self.stderr.write(err_msg)
sys.exit(1)
raise CommandError(str(exc_val)) from exc_val
Expand Down
2 changes: 1 addition & 1 deletion django_typer/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_command_line(self):
)

def test_cmd_name(self):
self.assertEqual(get_command("shellcompletion").name, "shellcompletion")
self.assertEqual(get_command("shellcompletion")._name, "shellcompletion")

def test_call_command(self):
out = StringIO()
Expand Down
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change Log
v1.0.2
======

* Fixed `name property on TyperCommand is too generic and should be private. <https://github.com/bckohan/django-typer/issues/37>`_
* Fixed `When usage errors are thrown the help output should be that of the subcommand invoked not the parent group. <https://github.com/bckohan/django-typer/issues/36>`_
* Fixed `typer installs its own system exception hook when commands are run and this may step on the installed rich hook <https://github.com/bckohan/django-typer/issues/35>`_
* Fixed `Add py.typed stub <https://github.com/bckohan/django-typer/issues/31>`_
Expand Down

0 comments on commit cdbefaa

Please sign in to comment.