diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py index 7e7c475359..de5085b3cb 100644 --- a/zerver/tests/test_openapi.py +++ b/zerver/tests/test_openapi.py @@ -346,12 +346,12 @@ so maybe we shouldn't mark it as intentionally undocumented in the urls. E.g. typing.Union[typing.List[typing.Dict[str, typing.Any]], NoneType] needs to be mapped to list.""" - if sys.version_info < (3, 6) and type(t) is type(Union): # nocoverage # in python3.6+ - origin = Union - else: # nocoverage # in python3.5. I.E. this is used in python3.6+ - origin = getattr(t, "__origin__", None) - - if sys.version_info > (3, 6): # nocoverage # in < python3.7 + if sys.version_info < (3, 7): # nocoverage # python 3.5-3.6 + if sys.version_info < (3, 6) and type(t) is type(Union): # python 3.5 has special consideration for Union + origin = Union + else: + origin = getattr(t, "__origin__", None) + else: # nocoverage # python3.7+ origin = getattr(t, "__origin__", None) t_name = getattr(t, "_name", None) if origin == list: