From 5c6c6570be3cfdf5b7933d9db90fafb1c56c5f1e Mon Sep 17 00:00:00 2001 From: konichuvak Date: Sat, 17 Jun 2023 22:37:20 -0400 Subject: [PATCH] Bumps the version of `typing_extensions` to include `Self` Type --- setup.py | 3 +-- web3/_utils/compat/__init__.py | 22 +++++++--------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index b6572d9871..9b311d73e6 100644 --- a/setup.py +++ b/setup.py @@ -80,8 +80,7 @@ "protobuf>=4.21.6", "pywin32>=223;platform_system=='Windows'", "requests>=2.16.0", - # remove typing_extensions after python_requires>=3.8, see web3._utils.compat - "typing-extensions>=3.7.4.1,<5;python_version<'3.8'", + "typing-extensions>=4.0.1,<5", "websockets>=10.0.0", ], python_requires=">=3.7.2", diff --git a/web3/_utils/compat/__init__.py b/web3/_utils/compat/__init__.py index 72ef20f19a..76d76373be 100644 --- a/web3/_utils/compat/__init__.py +++ b/web3/_utils/compat/__init__.py @@ -1,16 +1,8 @@ -import sys +# Changelog for `typing_extensions` for checking which types were added when +# https://github.com/python/typing_extensions/blob/main/CHANGELOG.md -# remove once web3 supports python>=3.8 -# Types was added to typing in 3.8 -if sys.version_info >= (3, 8): - from typing import ( - Literal, - Protocol, - TypedDict, - ) -else: - from typing_extensions import ( # noqa: F401 - Literal, - Protocol, - TypedDict, - ) +# Note that we do not need to explicitly check for python version here, +# because `typing_extensions` will do it for us and either import from `typing` +# or use the back-ported version of the type. + +from typing_extensions import Literal, Protocol, TypedDict, Self