From d2aa484d4d111ae7e7302dcb6a31d206498462a3 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Fri, 8 May 2020 15:30:06 +0200 Subject: [PATCH 1/2] Import Literal type from typing_extensions if python version <3.8 --- immutables/_map.pyi | 7 ++++++- setup.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/immutables/_map.pyi b/immutables/_map.pyi index bea69f321..ccfeda724 100644 --- a/immutables/_map.pyi +++ b/immutables/_map.pyi @@ -1,9 +1,9 @@ +import sys from typing import Any from typing import Generic from typing import Hashable from typing import Iterable from typing import Iterator -from typing import Literal from typing import Mapping from typing import MutableMapping from typing import NoReturn @@ -13,6 +13,11 @@ from typing import Type from typing import TypeVar from typing import Union +if sys.version_info < (3, 8): + from typing_extensions import Literal +else: + from typing import Literal + K = TypeVar('K', bound=Hashable) V = TypeVar('V', bound=Any) diff --git a/setup.py b/setup.py index b54270dc9..38f822f8b 100644 --- a/setup.py +++ b/setup.py @@ -71,6 +71,7 @@ package_data={"immutables": ["py.typed", "*.pyi"]}, provides=['immutables'], include_package_data=True, + install_requires=["typing-extensions; python_version<'3.8'"], ext_modules=ext_modules, test_suite='tests.suite', ) From ff028ec3740874aa0cfff73060cac3eb98aee3df Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Wed, 13 May 2020 21:20:43 +0200 Subject: [PATCH 2/2] Address PR review: remove use of typing.Literal --- immutables/_map.pyi | 8 +------- setup.py | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/immutables/_map.pyi b/immutables/_map.pyi index ccfeda724..7b20573c1 100644 --- a/immutables/_map.pyi +++ b/immutables/_map.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any from typing import Generic from typing import Hashable @@ -13,11 +12,6 @@ from typing import Type from typing import TypeVar from typing import Union -if sys.version_info < (3, 8): - from typing_extensions import Literal -else: - from typing import Literal - K = TypeVar('K', bound=Hashable) V = TypeVar('V', bound=Any) @@ -80,7 +74,7 @@ class MapMutation(MutableMapping[K, V]): def __init__(self, count: int, root: BitmapNode) -> None: ... def set(self, key: K, val: V) -> None: ... def __enter__(self: S) -> S: ... - def __exit__(self, *exc: Any) -> Literal[False]: ... + def __exit__(self, *exc: Any): ... def __iter__(self) -> NoReturn: ... def __delitem__(self, key: K) -> None: ... def __setitem__(self, key: K, val: V) -> None: ... diff --git a/setup.py b/setup.py index 38f822f8b..b54270dc9 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,6 @@ package_data={"immutables": ["py.typed", "*.pyi"]}, provides=['immutables'], include_package_data=True, - install_requires=["typing-extensions; python_version<'3.8'"], ext_modules=ext_modules, test_suite='tests.suite', )