From c2f91a27ee28dd1817db08b5f2bc98dcf2e2c305 Mon Sep 17 00:00:00 2001 From: 1maple1 <160027655+1maple1@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:14:28 +0000 Subject: [PATCH] Allow parameter decorator to passthrough None for type --- brewtils/decorators.py | 27 ++++++++++++++------------- test/decorators_test.py | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/brewtils/decorators.py b/brewtils/decorators.py index b27019be..7186aaa5 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -297,19 +297,20 @@ def echo(self, message): """ # Validate type against permitted string literals - if not isinstance(type, str): - # Try to map literal to string equivalent - temp_type = _format_type(type) - if temp_type in Parameter.TYPES: - type = temp_type - elif type not in Parameter.TYPES: - # Allowing type matching: string == String == STRING - for parameter_type in Parameter.TYPES: - if type.upper() == parameter_type.upper(): - type = parameter_type - break - if type not in Parameter.TYPES: - raise ValueError(f"Unable to map type {type} to string literal") + if type: + if not isinstance(type, str): + # Try to map literal to string equivalent + temp_type = _format_type(type) + if temp_type in Parameter.TYPES: + type = temp_type + elif type not in Parameter.TYPES: + # Allowing type matching: string == String == STRING + for parameter_type in Parameter.TYPES: + if type.upper() == parameter_type.upper(): + type = parameter_type + break + if type not in Parameter.TYPES: + raise ValueError(f"Unable to map type {type} to string literal") if _wrapped is None: return functools.partial( diff --git a/test/decorators_test.py b/test/decorators_test.py index 7ab81dca..4a5e3204 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -731,7 +731,7 @@ def cmd6(foo): assert cmd3.parameters[0].type == "Float" assert cmd4.parameters[0].type == "Boolean" assert cmd5.parameters[0].type == "Dictionary" - assert cmd6.parameters[0].type == "Any" + assert cmd6.parameters[0].type == None with pytest.raises(ValueError):