From 5fda7e7b07675462c09f481db9ba25b05aec8d7f Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 29 Mar 2022 13:04:01 -0400 Subject: [PATCH 1/3] Rerun new black version --- adafruit_requests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_requests.py b/adafruit_requests.py index 20535d4..c8ae170 100644 --- a/adafruit_requests.py +++ b/adafruit_requests.py @@ -47,7 +47,6 @@ def cast(_t, value): """No-op shim for the typing.cast() function which is not available in CircuitPython.""" return value - else: from ssl import SSLContext from types import ModuleType, TracebackType From 08e31ca9cd3e9a808625a67a4574cc0962cc33b1 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 29 Mar 2022 13:07:01 -0400 Subject: [PATCH 2/3] Add backup import of Protocol from typing_extensions --- adafruit_requests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/adafruit_requests.py b/adafruit_requests.py index c8ae170..2f3e252 100644 --- a/adafruit_requests.py +++ b/adafruit_requests.py @@ -50,7 +50,12 @@ def cast(_t, value): else: from ssl import SSLContext from types import ModuleType, TracebackType - from typing import Any, Dict, List, Optional, Protocol, Tuple, Type, Union, cast + from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast + +try: + from typing import Protocol +except ImportError: + from typing_extensions import Protocol # Based on https://github.com/python/typeshed/blob/master/stdlib/_socket.pyi class CommonSocketType(Protocol): From cf17c20921b5f973f4120a99bf0d4b7c03fdf14a Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 29 Mar 2022 13:14:03 -0400 Subject: [PATCH 3/3] Place Protocol import in else block --- adafruit_requests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_requests.py b/adafruit_requests.py index 2f3e252..9b5bc00 100644 --- a/adafruit_requests.py +++ b/adafruit_requests.py @@ -52,10 +52,10 @@ def cast(_t, value): from types import ModuleType, TracebackType from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast -try: - from typing import Protocol -except ImportError: - from typing_extensions import Protocol + try: + from typing import Protocol + except ImportError: + from typing_extensions import Protocol # Based on https://github.com/python/typeshed/blob/master/stdlib/_socket.pyi class CommonSocketType(Protocol):