diff --git a/brewtils/decorators.py b/brewtils/decorators.py index ec40fa30..3cf28c06 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -18,7 +18,8 @@ from funcsigs import signature, Parameter as InspectParameter # noqa else: from inspect import signature, Parameter as InspectParameter # noqa - if (sys.version_info.major == 3 and sys.version_info.minor >= 8): + + if sys.version_info.major == 3 and sys.version_info.minor >= 8: from typing import get_args __all__ = [ @@ -564,8 +565,9 @@ def _parameter_docstring(method, parameter): return None + def _choices_type_hint(method, cmd_parameter): - if (sys.version_info.major == 3 and sys.version_info.minor >= 8): + if sys.version_info.major == 3 and sys.version_info.minor >= 8: for _, arg in enumerate(signature(method).parameters.values()): if arg.name == cmd_parameter: if str(arg.annotation).startswith("typing.Literal"): @@ -576,6 +578,7 @@ def _choices_type_hint(method, cmd_parameter): return None + def _parameter_type_hint(method, cmd_parameter): for _, arg in enumerate(signature(method).parameters.values()): if arg.name == cmd_parameter: diff --git a/test/decorators_test.py b/test/decorators_test.py index 85d7e4e9..e19640d0 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -6,7 +6,7 @@ import pytest from mock import Mock -if (sys.version_info.major == 3 and sys.version_info.minor >= 8): +if sys.version_info.major == 3 and sys.version_info.minor >= 8: from typing import Literal import brewtils.decorators @@ -212,9 +212,10 @@ def cmd(foo: int) -> dict: assert bg_cmd.output_type == "JSON" def test_type_hints_choices(self): - if (sys.version_info.major == 3 and sys.version_info.minor >= 8): + if sys.version_info.major == 3 and sys.version_info.minor >= 8: + @command - def cmd(foo: Literal["a","b"] = "a") -> dict: + def cmd(foo: Literal["a", "b"] = "a") -> dict: return foo bg_cmd = _parse_method(cmd) @@ -222,8 +223,8 @@ def cmd(foo: Literal["a","b"] = "a") -> dict: assert len(bg_cmd.parameters) == 1 assert bg_cmd.parameters[0].key == "foo" assert bg_cmd.parameters[0].type == "Any" - assert bg_cmd.parameters[0].choices.value == ["a","b"] - assert bg_cmd.parameters[0].default == "a" + assert bg_cmd.parameters[0].choices.value == ["a", "b"] + assert bg_cmd.parameters[0].default == "a" assert bg_cmd.parameters[0].optional is True class TestDocString(object):