Skip to content

Commit 9cc1bb2

Browse files
committed
mypy typing module version fix
1 parent 3cc812f commit 9cc1bb2

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

openapi_core/contrib/requests/protocols.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
from typing import TYPE_CHECKING
1+
import sys
22

3-
if TYPE_CHECKING:
3+
if sys.version_info >= (3, 8):
4+
from typing import Protocol
5+
from typing import runtime_checkable
6+
else:
47
from typing_extensions import Protocol
58
from typing_extensions import runtime_checkable
6-
else:
7-
try:
8-
from typing import Protocol
9-
from typing import runtime_checkable
10-
except ImportError:
11-
from typing_extensions import Protocol
12-
from typing_extensions import runtime_checkable
139

1410
from requests.cookies import RequestsCookieJar
1511

openapi_core/schema/protocols.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
from typing import TYPE_CHECKING
1+
import sys
22
from typing import Any
33
from typing import List
44

5-
if TYPE_CHECKING:
5+
if sys.version_info >= (3, 8):
6+
from typing import Protocol
7+
from typing import runtime_checkable
8+
else:
69
from typing_extensions import Protocol
710
from typing_extensions import runtime_checkable
8-
else:
9-
try:
10-
from typing import Protocol
11-
from typing import runtime_checkable
12-
except ImportError:
13-
from typing_extensions import Protocol
14-
from typing_extensions import runtime_checkable
1511

1612

1713
@runtime_checkable

openapi_core/validation/request/protocols.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
"""OpenAPI core validation request protocols module"""
2-
from typing import TYPE_CHECKING
2+
import sys
33
from typing import Optional
44

5-
if TYPE_CHECKING:
5+
if sys.version_info >= (3, 8):
6+
from typing import Protocol
7+
from typing import runtime_checkable
8+
else:
69
from typing_extensions import Protocol
710
from typing_extensions import runtime_checkable
8-
else:
9-
try:
10-
from typing import Protocol
11-
from typing import runtime_checkable
12-
except ImportError:
13-
from typing_extensions import Protocol
14-
from typing_extensions import runtime_checkable
1511

1612
from openapi_core.spec import Spec
1713
from openapi_core.validation.request.datatypes import RequestParameters

openapi_core/validation/response/protocols.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
"""OpenAPI core validation response protocols module"""
2-
from typing import TYPE_CHECKING
2+
import sys
33
from typing import Any
44
from typing import Mapping
55
from typing import Optional
66

7-
if TYPE_CHECKING:
7+
if sys.version_info >= (3, 8):
8+
from typing import Protocol
9+
from typing import runtime_checkable
10+
else:
811
from typing_extensions import Protocol
912
from typing_extensions import runtime_checkable
10-
else:
11-
try:
12-
from typing import Protocol
13-
from typing import runtime_checkable
14-
except ImportError:
15-
from typing_extensions import Protocol
16-
from typing_extensions import runtime_checkable
1713

1814
from openapi_core.spec import Spec
1915
from openapi_core.validation.request.protocols import Request

0 commit comments

Comments
 (0)