Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_openapi: Use Python 3.8 typing.{get_origin,get_args}.
Anders Kaseorg7c247a11a9e3
diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.pyindex 183c2e6e820..27db61f136d 100644--- a/zerver/tests/test_openapi.py+++ b/zerver/tests/test_openapi.py@@ -1,7 +1,19 @@import inspectimport osfrom collections import abc-from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Union+from typing import (+ Any,+ Callable,+ Dict,+ List,+ Optional,+ Sequence,+ Set,+ Tuple,+ Union,+ get_args,+ get_origin,+)from unittest.mock import MagicMock, patchimport yaml@@ -326,17 +338,17 @@ 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."""- origin = getattr(t, "__origin__", None)+ origin = get_origin(t)- if not origin:+ if origin is None:# Then it's most likely one of the fundamental data types# I.E. Not one of the data types from the "typing" module.return telif origin == Union:- subtypes = [self.get_standardized_argument_type(st) for st in t.__args__]+ subtypes = [self.get_standardized_argument_type(st) for st in get_args(t)]return self.get_type_by_priority(subtypes)elif origin in [list, abc.Sequence]:- [st] = t.__args__+ [st] = get_args(t)return (list, self.get_standardized_argument_type(st))elif origin in [dict, abc.Mapping]:return dict