Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6c714b

Browse filesBrowse files
authored
types: Only use typing-extensions if necessary (#563)
As discussed in #562 - a second PR that contains the change that makes the use of typing-extensions conditional on the Python version.
2 parents e961eae + 0eda710 commit b6c714b
Copy full SHA for b6c714b

File tree

Expand file treeCollapse file tree

4 files changed

+24
-5
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+24
-5
lines changed

‎src/libtmux/server.py

Copy file name to clipboardExpand all lines: src/libtmux/server.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@
3535
)
3636

3737
if t.TYPE_CHECKING:
38+
import sys
3839
import types
3940

40-
from typing_extensions import TypeAlias
41+
if sys.version_info >= (3, 10):
42+
from typing import TypeAlias
43+
else:
44+
from typing_extensions import TypeAlias
4145

4246
DashLiteral: TypeAlias = t.Literal["-"]
4347

‎src/libtmux/test.py

Copy file name to clipboardExpand all lines: src/libtmux/test.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@
1515
logger = logging.getLogger(__name__)
1616

1717
if t.TYPE_CHECKING:
18+
import sys
1819
import types
1920
from collections.abc import Callable, Generator
2021

21-
from typing_extensions import Self
22-
2322
from libtmux.server import Server
2423
from libtmux.session import Session
2524
from libtmux.window import Window
2625

26+
if sys.version_info >= (3, 11):
27+
from typing import Self
28+
else:
29+
from typing_extensions import Self
30+
31+
2732
TEST_SESSION_PREFIX = "libtmux_"
2833
RETRY_TIMEOUT_SECONDS = int(os.getenv("RETRY_TIMEOUT_SECONDS", 8))
2934
RETRY_INTERVAL_SECONDS = float(os.getenv("RETRY_INTERVAL_SECONDS", 0.05))

‎tests/legacy_api/test_version.py

Copy file name to clipboardExpand all lines: tests/legacy_api/test_version.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
from libtmux._compat import LooseVersion
1212

1313
if t.TYPE_CHECKING:
14+
import sys
1415
from collections.abc import Callable
1516

1617
from _pytest.python_api import RaisesContext
17-
from typing_extensions import TypeAlias
18+
19+
if sys.version_info >= (3, 10):
20+
from typing import TypeAlias
21+
else:
22+
from typing_extensions import TypeAlias
1823

1924
VersionCompareOp: TypeAlias = Callable[
2025
[t.Any, t.Any],

‎tests/test_version.py

Copy file name to clipboardExpand all lines: tests/test_version.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
from libtmux._compat import LooseVersion
1212

1313
if t.TYPE_CHECKING:
14+
import sys
1415
from collections.abc import Callable
1516

1617
from _pytest.python_api import RaisesContext
17-
from typing_extensions import TypeAlias
18+
19+
if sys.version_info >= (3, 10):
20+
from typing import TypeAlias
21+
else:
22+
from typing_extensions import TypeAlias
1823

1924
VersionCompareOp: TypeAlias = Callable[
2025
[t.Any, t.Any],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.