Skip to content

Commit

Permalink
style(MYPY): missing typing for click
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Jul 10, 2023
1 parent 4a47dac commit 399751b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
17 changes: 9 additions & 8 deletions mac_maker/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# type: ignore[misc]
"""The Mac Maker CLI."""

from typing import Optional
Expand All @@ -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.)",
)
Expand All @@ -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',
Expand All @@ -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.
Expand All @@ -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',
Expand All @@ -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.
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion mac_maker/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions mac_maker/tests/test_cli_shell_interrupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@


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()

@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):
Expand Down
3 changes: 2 additions & 1 deletion mac_maker/utilities/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 399751b

Please sign in to comment.