Skip to content

Commit 6450ef8

Browse files
mgxdap--
andauthored
DEP: Ensure typing_extension is dependency for earlier python versions (#290)
* DEP: Ensure typing_extension is dependency for earlier python versions * RF: Guard type definition to explicit type checking, add typing_extensions to [dev] extra * fix linting --------- Co-authored-by: Andreas Poehlmann <[email protected]>
1 parent 5486fa3 commit 6450ef8

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dev = [
6161
"pydantic",
6262
"pydantic-settings",
6363
"smbprotocol",
64+
"typing_extensions; python_version<'3.11'",
6465
]
6566

6667
[project.urls]

upath/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
from typing import overload
2020
from urllib.parse import urlsplit
2121

22-
if sys.version_info >= (3, 11):
23-
from typing import Self
24-
else:
25-
from typing_extensions import Self
26-
2722
from fsspec.registry import get_filesystem_class
2823
from fsspec.spec import AbstractFileSystem
2924

@@ -43,6 +38,11 @@
4338
if TYPE_CHECKING:
4439
from urllib.parse import SplitResult
4540

41+
if sys.version_info >= (3, 11):
42+
from typing import Self
43+
else:
44+
from typing_extensions import Self
45+
4646
__all__ = ["UPath"]
4747

4848

upath/implementations/sftp.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from __future__ import annotations
22

33
import sys
4+
from typing import TYPE_CHECKING
45
from typing import Any
56
from typing import Generator
67

7-
if sys.version_info >= (3, 11):
8-
from typing import Self
9-
else:
10-
from typing_extensions import Self
8+
if TYPE_CHECKING:
9+
if sys.version_info >= (3, 11):
10+
from typing import Self
11+
else:
12+
from typing_extensions import Self
1113

1214
from upath import UPath
1315

upath/implementations/smb.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import os
44
import sys
55
import warnings
6+
from typing import TYPE_CHECKING
67
from typing import Any
78

8-
if sys.version_info >= (3, 11):
9-
from typing import Self
10-
else:
11-
from typing_extensions import Self
9+
if TYPE_CHECKING:
10+
if sys.version_info >= (3, 11):
11+
from typing import Self
12+
else:
13+
from typing_extensions import Self
1214

1315
import smbprotocol.exceptions
1416

0 commit comments

Comments
 (0)