Skip to content

Commit

Permalink
chore: Refine imports to use t namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jan 4, 2025
1 parent ebba849 commit 25bc266
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 33 deletions.
16 changes: 8 additions & 8 deletions src/libtmux/_vendor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
import collections
import itertools
import re
from typing import Callable, SupportsInt, Union
import typing as t

from ._structures import Infinity, InfinityType, NegativeInfinity, NegativeInfinityType

__all__ = ["VERSION_PATTERN", "InvalidVersion", "Version", "parse"]

InfiniteTypes = Union[InfinityType, NegativeInfinityType]
PrePostDevType = Union[InfiniteTypes, tuple[str, int]]
SubLocalType = Union[InfiniteTypes, int, str]
LocalType = Union[
InfiniteTypes = t.Union[InfinityType, NegativeInfinityType]
PrePostDevType = t.Union[InfiniteTypes, tuple[str, int]]
SubLocalType = t.Union[InfiniteTypes, int, str]
LocalType = t.Union[
NegativeInfinityType,
tuple[
Union[
t.Union[
SubLocalType,
tuple[SubLocalType, str],
tuple[NegativeInfinityType, SubLocalType],
Expand All @@ -42,7 +42,7 @@
PrePostDevType,
LocalType,
]
VersionComparisonMethod = Callable[[CmpKey, CmpKey], bool]
VersionComparisonMethod = t.Callable[[CmpKey, CmpKey], bool]

_Version = collections.namedtuple(
"_Version",
Expand Down Expand Up @@ -477,7 +477,7 @@ def micro(self) -> int:

def _parse_letter_version(
letter: str,
number: str | bytes | SupportsInt,
number: str | bytes | t.SupportsInt,
) -> tuple[str, int] | None:
if letter:
# We consider there to be an implicit 0 in a pre-release if there is
Expand Down
5 changes: 2 additions & 3 deletions src/libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pathlib
import typing as t
import warnings
from typing import overload

from libtmux.common import has_gte_version, has_lt_version, tmux_cmd
from libtmux.constants import (
Expand Down Expand Up @@ -349,14 +348,14 @@ def send_keys(
if enter:
self.enter()

@overload
@t.overload
def display_message(
self,
cmd: str,
get_text: t.Literal[True],
) -> str | list[str]: ...

@overload
@t.overload
def display_message(self, cmd: str, get_text: t.Literal[False]) -> None: ...

def display_message(
Expand Down
3 changes: 1 addition & 2 deletions src/libtmux/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import random
import time
import typing as t
from typing import Callable

from typing_extensions import Self

Expand Down Expand Up @@ -65,7 +64,7 @@ def __next__(self) -> str:


def retry_until(
fun: Callable[[], bool],
fun: t.Callable[[], bool],
seconds: float = RETRY_TIMEOUT_SECONDS,
*,
interval: float = RETRY_INTERVAL_SECONDS,
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import logging
import shutil
from typing import TYPE_CHECKING
import typing as t

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import logging
import subprocess
from typing import TYPE_CHECKING
import typing as t

import pytest

from libtmux.common import has_gte_version
from libtmux.server import Server

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging
import shutil
from typing import TYPE_CHECKING
import typing as t

import pytest

Expand All @@ -15,7 +15,7 @@
from libtmux.test import TEST_SESSION_PREFIX, namer
from libtmux.window import Window

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.server import Server

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_tmuxobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING
import typing as t

from libtmux.pane import Pane
from libtmux.session import Session
from libtmux.test import TEST_SESSION_PREFIX, namer
from libtmux.window import Window

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.server import Server

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import shutil
import time
from typing import TYPE_CHECKING
import typing as t

import pytest

Expand All @@ -15,7 +15,7 @@
from libtmux.server import Server
from libtmux.window import Window

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

import logging
import shutil
from typing import TYPE_CHECKING
import typing as t

import pytest

from libtmux.common import has_gte_version, has_lt_version, has_lte_version
from libtmux.constants import PaneDirection, ResizeAdjustmentDirection
from libtmux.test import retry_until

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import textwrap
from typing import TYPE_CHECKING
import typing as t

if TYPE_CHECKING:
if t.TYPE_CHECKING:
import pytest


Expand Down
4 changes: 2 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import os
import subprocess
import time
from typing import TYPE_CHECKING
import typing as t

import pytest

from libtmux.common import has_gte_version, has_version
from libtmux.server import Server

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tmuxobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING
import typing as t

from libtmux.pane import Pane
from libtmux.session import Session
from libtmux.test import TEST_SESSION_PREFIX, namer
from libtmux.window import Window

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.server import Server

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import shutil
import time
from typing import TYPE_CHECKING
import typing as t

import pytest

Expand All @@ -21,7 +21,7 @@
from libtmux.server import Server
from libtmux.window import Window

if TYPE_CHECKING:
if t.TYPE_CHECKING:
from libtmux.session import Session

logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 25bc266

Please sign in to comment.