Skip to content

Commit df8480c

Browse files
committed
chore(ruff) Automated fixes for typing annotations
Fixed 21 errors: - src/libtmux/_internal/query_list.py: 2 × UP006 (non-pep585-annotation) 1 × I001 (unsorted-imports) - src/libtmux/common.py: 1 × I001 (unsorted-imports) 1 × UP006 (non-pep585-annotation) - src/libtmux/neo.py: 2 × UP006 (non-pep585-annotation) 1 × I001 (unsorted-imports) - src/libtmux/test.py: 2 × UP006 (non-pep585-annotation) 1 × I001 (unsorted-imports) - tests/_internal/test_query_list.py: 1 × I001 (unsorted-imports) 1 × UP006 (non-pep585-annotation) - tests/legacy_api/test_version.py: 2 × I001 (unsorted-imports) 1 × UP006 (non-pep585-annotation) 1 × TC003 (typing-only-standard-library-import) - tests/test_version.py: 2 × I001 (unsorted-imports) 1 × UP006 (non-pep585-annotation) 1 × TC003 (typing-only-standard-library-import) Found 1729 errors (21 fixed, 1708 remaining). 44 files left unchanged uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format .
1 parent 3fcb49a commit df8480c

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

src/libtmux/_internal/query_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
import traceback
1111
import typing as t
12-
from collections.abc import Iterable, Mapping, Sequence
12+
from collections.abc import Callable, Iterable, Mapping, Sequence
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -505,7 +505,7 @@ def __eq__(
505505

506506
def filter(
507507
self,
508-
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
508+
matcher: t.Optional[t.Union[Callable[[T], bool], T]] = None,
509509
**kwargs: t.Any,
510510
) -> "QueryList[T]":
511511
"""Filter list of objects."""
@@ -547,7 +547,7 @@ def val_match(obj: t.Union[str, list[t.Any], T]) -> bool:
547547

548548
def get(
549549
self,
550-
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
550+
matcher: t.Optional[t.Union[Callable[[T], bool], T]] = None,
551551
default: t.Optional[t.Any] = no_arg,
552552
**kwargs: t.Any,
553553
) -> t.Optional[T]:

src/libtmux/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import subprocess
1212
import sys
1313
import typing as t
14+
from collections.abc import Callable
1415
from typing import Optional, Union
1516

1617
from . import exc
@@ -36,7 +37,7 @@ class EnvironmentMixin:
3637

3738
_add_option = None
3839

39-
cmd: t.Callable[[t.Any, t.Any], "tmux_cmd"]
40+
cmd: Callable[[t.Any, t.Any], "tmux_cmd"]
4041

4142
def __init__(self, add_option: Optional[str] = None) -> None:
4243
self._add_option = add_option

src/libtmux/neo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import dataclasses
44
import logging
55
import typing as t
6+
from collections.abc import Iterable
67

78
from libtmux import exc
89
from libtmux.common import tmux_cmd
910
from libtmux.formats import FORMAT_SEPARATOR
1011

1112
if t.TYPE_CHECKING:
1213
ListCmd = t.Literal["list-sessions", "list-windows", "list-panes"]
13-
ListExtraArgs = t.Optional[t.Iterable[str]]
14+
ListExtraArgs = t.Optional[Iterable[str]]
1415

1516
from libtmux.server import Server
1617

@@ -208,7 +209,7 @@ def fetch_objs(
208209
list_cmd,
209210
]
210211

211-
if list_extra_args is not None and isinstance(list_extra_args, t.Iterable):
212+
if list_extra_args is not None and isinstance(list_extra_args, Iterable):
212213
tmux_cmds.extend(list(list_extra_args))
213214

214215
tmux_cmds.append("-F{}".format("".join(tmux_formats)))

src/libtmux/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import time
99
import types
1010
import typing as t
11+
from collections.abc import Generator
1112
from typing import Callable, Optional
1213

1314
from libtmux.server import Server
@@ -185,7 +186,7 @@ def temp_session(
185186
server: Server,
186187
*args: t.Any,
187188
**kwargs: t.Any,
188-
) -> t.Generator["Session", t.Any, t.Any]:
189+
) -> Generator["Session", t.Any, t.Any]:
189190
"""
190191
Return a context manager with a temporary session.
191192
@@ -236,7 +237,7 @@ def temp_window(
236237
session: "Session",
237238
*args: t.Any,
238239
**kwargs: t.Any,
239-
) -> t.Generator["Window", t.Any, t.Any]:
240+
) -> Generator["Window", t.Any, t.Any]:
240241
"""
241242
Return a context manager with a temporary window.
242243

tests/_internal/test_query_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dataclasses
22
import typing as t
3+
from collections.abc import Callable
34

45
import pytest
56

@@ -250,7 +251,7 @@ class Obj:
250251
)
251252
def test_filter(
252253
items: list[dict[str, t.Any]],
253-
filter_expr: t.Optional[t.Union[t.Callable[[t.Any], bool], t.Any]],
254+
filter_expr: t.Optional[t.Union[Callable[[t.Any], bool], t.Any]],
254255
expected_result: t.Union[QueryList[t.Any], list[dict[str, t.Any]]],
255256
) -> None:
256257
qs = QueryList(items)

tests/legacy_api/test_version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
from libtmux._compat import LooseVersion
1010

1111
if t.TYPE_CHECKING:
12+
from collections.abc import Callable
13+
1214
from _pytest.python_api import RaisesContext
1315
from typing_extensions import TypeAlias
1416

15-
VersionCompareOp: TypeAlias = t.Callable[
17+
VersionCompareOp: TypeAlias = Callable[
1618
[t.Any, t.Any],
1719
bool,
1820
]

tests/test_version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
from libtmux._compat import LooseVersion
1010

1111
if t.TYPE_CHECKING:
12+
from collections.abc import Callable
13+
1214
from _pytest.python_api import RaisesContext
1315
from typing_extensions import TypeAlias
1416

15-
VersionCompareOp: TypeAlias = t.Callable[
17+
VersionCompareOp: TypeAlias = Callable[
1618
[t.Any, t.Any],
1719
bool,
1820
]

0 commit comments

Comments
 (0)