Skip to content

Commit db06c6e

Browse files
authored
fix(typings) Move typing-extensions into TypeGuard (#572)
Resolves #571, follow up to #564.
2 parents 29451c2 + 024259a commit db06c6e

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ $ pip install --user --upgrade --pre libtmux
1515

1616
- _Future release notes will be placed here_
1717

18+
### Bug fix
19+
20+
- Fix `typing_extensions` issue by wrapping it in `TYPE_CHECKING`, continuation of #564, via #572.
21+
1822
### Development
1923

2024
- Improved test organization and coverage in `test_common.py` (#570):

src/libtmux/pane.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import typing as t
1414
import warnings
1515

16-
from typing_extensions import Self
17-
1816
from libtmux.common import has_gte_version, has_lt_version, tmux_cmd
1917
from libtmux.constants import (
2018
PANE_DIRECTION_FLAG_MAP,
@@ -28,12 +26,17 @@
2826
from . import exc
2927

3028
if t.TYPE_CHECKING:
29+
import sys
3130
import types
3231

3332
from .server import Server
3433
from .session import Session
3534
from .window import Window
3635

36+
if sys.version_info >= (3, 11):
37+
from typing import Self
38+
else:
39+
from typing_extensions import Self
3740

3841
logger = logging.getLogger(__name__)
3942

src/libtmux/server.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import typing as t
1616
import warnings
1717

18-
from typing_extensions import Self
19-
2018
from libtmux._internal.query_list import QueryList
2119
from libtmux.common import tmux_cmd
2220
from libtmux.neo import fetch_objs
@@ -39,9 +37,9 @@
3937
import types
4038

4139
if sys.version_info >= (3, 10):
42-
from typing import TypeAlias
40+
from typing import Self, TypeAlias
4341
else:
44-
from typing_extensions import TypeAlias
42+
from typing_extensions import Self, TypeAlias
4543

4644
DashLiteral: TypeAlias = t.Literal["-"]
4745

src/libtmux/session.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import typing as t
1414
import warnings
1515

16-
from typing_extensions import Self
17-
1816
from libtmux._internal.query_list import QueryList
1917
from libtmux.constants import WINDOW_DIRECTION_FLAG_MAP, WindowDirection
2018
from libtmux.formats import FORMAT_SEPARATOR
@@ -33,10 +31,16 @@
3331
)
3432

3533
if t.TYPE_CHECKING:
34+
import sys
3635
import types
3736

3837
from libtmux.common import tmux_cmd
3938

39+
if sys.version_info >= (3, 11):
40+
from typing import Self
41+
else:
42+
from typing_extensions import Self
43+
4044
from .server import Server
4145

4246

src/libtmux/window.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import typing as t
1414
import warnings
1515

16-
from typing_extensions import Self
17-
1816
from libtmux._internal.query_list import QueryList
1917
from libtmux.common import has_gte_version, tmux_cmd
2018
from libtmux.constants import (
@@ -30,11 +28,18 @@
3028
from .common import PaneDict, WindowOptionDict, handle_option_error
3129

3230
if t.TYPE_CHECKING:
31+
import sys
3332
import types
3433

3534
from .server import Server
3635
from .session import Session
3736

37+
if sys.version_info >= (3, 11):
38+
from typing import Self
39+
else:
40+
from typing_extensions import Self
41+
42+
3843
logger = logging.getLogger(__name__)
3944

4045

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy