Skip to content

Commit

Permalink
chore(ruff) Automated fixes for typing annotations
Browse files Browse the repository at this point in the history
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 .
  • Loading branch information
tony committed Jan 4, 2025
1 parent 3fcb49a commit df8480c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/libtmux/_internal/query_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
import traceback
import typing as t
from collections.abc import Iterable, Mapping, Sequence
from collections.abc import Callable, Iterable, Mapping, Sequence

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -505,7 +505,7 @@ def __eq__(

def filter(
self,
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
matcher: t.Optional[t.Union[Callable[[T], bool], T]] = None,
**kwargs: t.Any,
) -> "QueryList[T]":
"""Filter list of objects."""
Expand Down Expand Up @@ -547,7 +547,7 @@ def val_match(obj: t.Union[str, list[t.Any], T]) -> bool:

def get(
self,
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
matcher: t.Optional[t.Union[Callable[[T], bool], T]] = None,
default: t.Optional[t.Any] = no_arg,
**kwargs: t.Any,
) -> t.Optional[T]:
Expand Down
3 changes: 2 additions & 1 deletion src/libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import subprocess
import sys
import typing as t
from collections.abc import Callable
from typing import Optional, Union

from . import exc
Expand All @@ -36,7 +37,7 @@ class EnvironmentMixin:

_add_option = None

cmd: t.Callable[[t.Any, t.Any], "tmux_cmd"]
cmd: Callable[[t.Any, t.Any], "tmux_cmd"]

def __init__(self, add_option: Optional[str] = None) -> None:
self._add_option = add_option
Expand Down
5 changes: 3 additions & 2 deletions src/libtmux/neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import dataclasses
import logging
import typing as t
from collections.abc import Iterable

from libtmux import exc
from libtmux.common import tmux_cmd
from libtmux.formats import FORMAT_SEPARATOR

if t.TYPE_CHECKING:
ListCmd = t.Literal["list-sessions", "list-windows", "list-panes"]
ListExtraArgs = t.Optional[t.Iterable[str]]
ListExtraArgs = t.Optional[Iterable[str]]

from libtmux.server import Server

Expand Down Expand Up @@ -208,7 +209,7 @@ def fetch_objs(
list_cmd,
]

if list_extra_args is not None and isinstance(list_extra_args, t.Iterable):
if list_extra_args is not None and isinstance(list_extra_args, Iterable):
tmux_cmds.extend(list(list_extra_args))

tmux_cmds.append("-F{}".format("".join(tmux_formats)))
Expand Down
5 changes: 3 additions & 2 deletions src/libtmux/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import types
import typing as t
from collections.abc import Generator
from typing import Callable, Optional

from libtmux.server import Server
Expand Down Expand Up @@ -185,7 +186,7 @@ def temp_session(
server: Server,
*args: t.Any,
**kwargs: t.Any,
) -> t.Generator["Session", t.Any, t.Any]:
) -> Generator["Session", t.Any, t.Any]:
"""
Return a context manager with a temporary session.
Expand Down Expand Up @@ -236,7 +237,7 @@ def temp_window(
session: "Session",
*args: t.Any,
**kwargs: t.Any,
) -> t.Generator["Window", t.Any, t.Any]:
) -> Generator["Window", t.Any, t.Any]:
"""
Return a context manager with a temporary window.
Expand Down
3 changes: 2 additions & 1 deletion tests/_internal/test_query_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dataclasses
import typing as t
from collections.abc import Callable

import pytest

Expand Down Expand Up @@ -250,7 +251,7 @@ class Obj:
)
def test_filter(
items: list[dict[str, t.Any]],
filter_expr: t.Optional[t.Union[t.Callable[[t.Any], bool], t.Any]],
filter_expr: t.Optional[t.Union[Callable[[t.Any], bool], t.Any]],
expected_result: t.Union[QueryList[t.Any], list[dict[str, t.Any]]],
) -> None:
qs = QueryList(items)
Expand Down
4 changes: 3 additions & 1 deletion tests/legacy_api/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
from libtmux._compat import LooseVersion

if t.TYPE_CHECKING:
from collections.abc import Callable

from _pytest.python_api import RaisesContext
from typing_extensions import TypeAlias

VersionCompareOp: TypeAlias = t.Callable[
VersionCompareOp: TypeAlias = Callable[
[t.Any, t.Any],
bool,
]
Expand Down
4 changes: 3 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
from libtmux._compat import LooseVersion

if t.TYPE_CHECKING:
from collections.abc import Callable

from _pytest.python_api import RaisesContext
from typing_extensions import TypeAlias

VersionCompareOp: TypeAlias = t.Callable[
VersionCompareOp: TypeAlias = Callable[
[t.Any, t.Any],
bool,
]
Expand Down

0 comments on commit df8480c

Please sign in to comment.