From 399751b7a630dd44dc118b3c8bb74e35c840ee59 Mon Sep 17 00:00:00 2001 From: Niall Byrne <9848926+niall-byrne@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:05:23 -0400 Subject: [PATCH] style(MYPY): missing typing for click --- mac_maker/cli.py | 17 +++++++++-------- mac_maker/tests/test_cli.py | 2 +- mac_maker/tests/test_cli_shell_interrupt.py | 4 ++-- mac_maker/utilities/cli.py | 3 ++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/mac_maker/cli.py b/mac_maker/cli.py index f6cf09d..306c800 100644 --- a/mac_maker/cli.py +++ b/mac_maker/cli.py @@ -1,3 +1,4 @@ +# type: ignore[misc] """The Mac Maker CLI.""" from typing import Optional @@ -9,7 +10,7 @@ from .utilities.shell import cmd_loop -@shell( # type: ignore[misc] +@shell( prompt='Mac Maker > ', intro="Welcome to Mac Maker. (Type 'help' to get started.)", ) @@ -23,17 +24,17 @@ def cli(debug: bool) -> None: logger.setup() -@cli.group("apply") # type: ignore[misc] +@cli.group("apply") def apply() -> None: """Apply an OSX Machine Profile to this system.""" -@cli.group("precheck") # type: ignore[misc] +@cli.group("precheck") def precheck() -> None: """Ensure an OSX Machine Profile is ready to be applied.""" -@precheck.command("github") # type: ignore[misc] +@precheck.command("github") @click.argument('github_url', type=click.STRING) @click.option( '--branch', @@ -50,7 +51,7 @@ def check_from_github(github_url: str, branch: Optional[str]) -> None: job.precheck() -@precheck.command("spec") # type: ignore[misc] +@precheck.command("spec") @click.argument('spec_file', type=click.STRING) def check_from_filesystem(spec_file: str) -> None: """Precheck an OSX Machine Profile from a spec.json file. @@ -61,7 +62,7 @@ def check_from_filesystem(spec_file: str) -> None: job.precheck() -@apply.command("github") # type: ignore[misc] +@apply.command("github") @click.argument('github_url', type=click.STRING) @click.option( '--branch', @@ -79,7 +80,7 @@ def apply_from_github(github_url: str, branch: Optional[str]) -> None: job.provision() -@apply.command("spec") # type: ignore[misc] +@apply.command("spec") @click.argument('spec_file', type=click.STRING) def apply_from_spec(spec_file: str) -> None: """Apply an OSX Machine Profile from a spec.json file. @@ -91,7 +92,7 @@ def apply_from_spec(spec_file: str) -> None: job.provision() -@cli.command("version") # type: ignore[misc] +@cli.command("version") def version() -> None: """Report the current Mac Maker version.""" job = jobs.VersionJob() diff --git a/mac_maker/tests/test_cli.py b/mac_maker/tests/test_cli.py index 497497c..0b9aa96 100644 --- a/mac_maker/tests/test_cli.py +++ b/mac_maker/tests/test_cli.py @@ -6,7 +6,7 @@ from click.testing import CliRunner from parameterized import parameterized_class from .. import cli as cli_module -from ..cli import cli +from ..cli import cli # type: ignore[attr-defined] from .fixtures import fixtures_git CLI_MODULE = cli_module.__name__ diff --git a/mac_maker/tests/test_cli_shell_interrupt.py b/mac_maker/tests/test_cli_shell_interrupt.py index dda116b..9dbe208 100644 --- a/mac_maker/tests/test_cli_shell_interrupt.py +++ b/mac_maker/tests/test_cli_shell_interrupt.py @@ -11,7 +11,7 @@ class TestCommandInterrupt(TestCase): - """The the command patched_method is patched into the CLI.""" + """Test the command patched_method is patched into the CLI.""" def setUp(self) -> None: self.runner = CliRunner() @@ -19,7 +19,7 @@ def setUp(self) -> None: @mock.patch(ROOT_MODULE + ".utilities.shell.cmd_loop.patch_interrupt") def test_make_command_interrupt(self, m_interrupt: mock.Mock) -> None: importlib.reload(cli) - cli_root = cli.cli + cli_root = cli.cli # type: ignore[attr-defined] original_postcmd = cli_root.shell.postcmd with self.assertRaises(SystemExit): diff --git a/mac_maker/utilities/cli.py b/mac_maker/utilities/cli.py index c3444cd..cc58f84 100644 --- a/mac_maker/utilities/cli.py +++ b/mac_maker/utilities/cli.py @@ -11,7 +11,8 @@ def was_started_without_shell() -> bool: :returns: A boolean indicating if the CLI was started without a shell. """ - for command in mac_maker.cli.cli.commands.keys(): + for command in mac_maker.cli.\ + cli.commands.keys(): # type: ignore[attr-defined] if command in sys.argv: return True return False