Skip to content

Commit

Permalink
MyPy / Black fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ModernMAK committed Oct 15, 2023
1 parent 36fd7f7 commit 4866ee5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/relic/sga/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
class RelicSgaCli(CliPluginGroup):
GROUP = "relic.cli.sga"

def _create_parser(self, command_group: Optional[_SubParsersAction] = None) -> ArgumentParser:
def _create_parser(
self, command_group: Optional[_SubParsersAction] = None
) -> ArgumentParser:
if command_group is None:
return ArgumentParser("sga")
else:
return command_group.add_parser("sga")


class RelicSgaUnpackCli(CliPlugin):

def _create_parser(self, command_group: Optional[_SubParsersAction] = None) -> ArgumentParser:
def _create_parser(
self, command_group: Optional[_SubParsersAction] = None
) -> ArgumentParser:
parser: ArgumentParser
if command_group is None:
parser = ArgumentParser("unpack")
Expand All @@ -38,7 +41,7 @@ def command(self, ns: Namespace) -> Optional[int]:

print(f"Unpacking `{infile}`")

def _callback(_1: FS, srcfile: str, _2: FS, _3: str):
def _callback(_1: FS, srcfile: str, _2: FS, _3: str) -> None:
print(f"\t\tUnpacking File `{srcfile}`")

fs.copy.copy_fs(f"sga://{infile}", f"osfs://{outdir}", on_copy=_callback)
Expand All @@ -49,7 +52,9 @@ def _callback(_1: FS, srcfile: str, _2: FS, _3: str):
class RelicSgaPackCli(CliPluginGroup):
GROUP = "relic.cli.sga.pack"

def _create_parser(self, command_group: Optional[_SubParsersAction] = None) -> ArgumentParser:
def _create_parser(
self, command_group: Optional[_SubParsersAction] = None
) -> ArgumentParser:
parser: ArgumentParser
if command_group is None:
parser = ArgumentParser("pack")
Expand All @@ -59,4 +64,3 @@ def _create_parser(self, command_group: Optional[_SubParsersAction] = None) -> A
# pack further delegates to version plugins

return parser

4 changes: 3 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import subprocess

# Local testing requires running `pip install -e "."`
from contextlib import redirect_stdout
from typing import Sequence
Expand All @@ -19,6 +20,7 @@ def test_run(self, args: Sequence[str], output: str, exit_code: int):

def test_run_with(self, args: Sequence[str], output: str, exit_code: int):
from relic.core.cli import cli_root

with io.StringIO() as f:
with redirect_stdout(f):
status = cli_root.run_with(*args)
Expand All @@ -34,7 +36,7 @@ def test_run_with(self, args: Sequence[str], output: str, exit_code: int):
_SGA_UNPACK_HELP = ["sga", "unpack", "-h"], """usage: relic sga unpack [-h]""", 0

_TESTS = [_SGA_HELP, _SGA_PACK_HELP, _SGA_UNPACK_HELP]
_TEST_IDS = [' '.join(_[0]) for _ in _TESTS]
_TEST_IDS = [" ".join(_[0]) for _ in _TESTS]


@pytest.mark.parametrize(["args", "output", "exit_code"], _TESTS, ids=_TEST_IDS)
Expand Down

0 comments on commit 4866ee5

Please sign in to comment.