Skip to content

Commit ed3a49a

Browse files
committed
chore(ruff) ruff v0.12 aggressive fixes
uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format . Fixed 28 errors: - src/libtmux/common.py: 2 × ISC003 (explicit-string-concatenation) - src/libtmux/pane.py: 1 × TC001 (typing-only-first-party-import) 1 × I001 (unsorted-imports) - src/libtmux/server.py: 1 × TC001 (typing-only-first-party-import) 1 × I001 (unsorted-imports) - src/libtmux/session.py: 1 × ISC003 (explicit-string-concatenation) - src/libtmux/window.py: 2 × ISC003 (explicit-string-concatenation) 1 × I001 (unsorted-imports) 1 × TC001 (typing-only-first-party-import) - tests/legacy_api/test_window.py: 1 × ISC003 (explicit-string-concatenation) - tests/test_pane.py: 1 × PLR6201 (literal-membership) 1 × TC001 (typing-only-first-party-import) 1 × COM812 (missing-trailing-comma) 1 × RUF027 (missing-f-string-syntax) - tests/test_server.py: 1 × PLR6201 (literal-membership) 1 × TC001 (typing-only-first-party-import) 1 × COM812 (missing-trailing-comma) 1 × RUF027 (missing-f-string-syntax) - tests/test_session.py: 1 × PLR6201 (literal-membership) 1 × TC001 (typing-only-first-party-import) 1 × COM812 (missing-trailing-comma) 1 × RUF027 (missing-f-string-syntax) - tests/test_window.py: 1 × PLR6201 (literal-membership) 1 × TC001 (typing-only-first-party-import) 1 × COM812 (missing-trailing-comma) 1 × RUF027 (missing-f-string-syntax) Found 1699 errors (28 fixed, 1671 remaining).
1 parent 3d64bb7 commit ed3a49a

File tree

10 files changed

+32
-25
lines changed

10 files changed

+32
-25
lines changed

src/libtmux/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ def has_minimum_version(raises: bool = True) -> bool:
418418
if raises:
419419
msg = (
420420
f"libtmux only supports tmux {TMUX_MIN_VERSION} and greater. This "
421-
+ f"system has {get_version()} installed. Upgrade your tmux to use "
422-
+ "libtmux."
421+
f"system has {get_version()} installed. Upgrade your tmux to use "
422+
"libtmux."
423423
)
424424
raise exc.VersionTooLow(msg)
425425
return False

src/libtmux/pane.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import warnings
1515

1616
from libtmux import exc
17-
from libtmux._internal.types import StrPath
1817
from libtmux.common import has_gte_version, has_lt_version, tmux_cmd
1918
from libtmux.constants import (
2019
PANE_DIRECTION_FLAG_MAP,
@@ -29,6 +28,8 @@
2928
import sys
3029
import types
3130

31+
from libtmux._internal.types import StrPath
32+
3233
from .server import Server
3334
from .session import Session
3435
from .window import Window

src/libtmux/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from libtmux import exc, formats
1919
from libtmux._internal.query_list import QueryList
20-
from libtmux._internal.types import StrPath
2120
from libtmux.common import tmux_cmd
2221
from libtmux.neo import fetch_objs
2322
from libtmux.pane import Pane
@@ -37,6 +36,8 @@
3736
import sys
3837
import types
3938

39+
from libtmux._internal.types import StrPath
40+
4041
if sys.version_info >= (3, 10):
4142
from typing import Self, TypeAlias
4243
else:

src/libtmux/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def attached_window(self) -> Window:
833833
"""
834834
warnings.warn(
835835
"Session.attached_window() is deprecated in favor of "
836-
+ "Session.active_window()",
836+
"Session.active_window()",
837837
category=DeprecationWarning,
838838
stacklevel=2,
839839
)

src/libtmux/window.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import warnings
1515

1616
from libtmux._internal.query_list import QueryList
17-
from libtmux._internal.types import StrPath
1817
from libtmux.common import has_gte_version, tmux_cmd
1918
from libtmux.constants import (
2019
RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP,
@@ -32,6 +31,8 @@
3231
import sys
3332
import types
3433

34+
from libtmux._internal.types import StrPath
35+
3536
from .server import Server
3637
from .session import Session
3738

@@ -793,7 +794,7 @@ def __repr__(self) -> str:
793794
"""Representation of :class:`Window` object."""
794795
return (
795796
f"{self.__class__.__name__}({self.window_id} "
796-
+ f"{self.window_index}:{self.window_name}, {self.session})"
797+
f"{self.window_index}:{self.window_name}, {self.session})"
797798
)
798799

799800
#
@@ -899,7 +900,7 @@ def split_window(
899900
# Deprecated in 3.1 in favor of -l
900901
warnings.warn(
901902
f'Deprecated in favor of size="{str(percent).rstrip("%")}%" '
902-
+ ' ("-l" flag) in tmux 3.1+.',
903+
' ("-l" flag) in tmux 3.1+.',
903904
category=DeprecationWarning,
904905
stacklevel=2,
905906
)

tests/legacy_api/test_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_split_percentage(
176176
if has_version("3.4"):
177177
pytest.skip(
178178
"tmux 3.4 has a split-window bug."
179-
+ " See https://github.com/tmux/tmux/pull/3840.",
179+
" See https://github.com/tmux/tmux/pull/3840.",
180180
)
181181
with pytest.warns(match="Deprecated in favor of size.*"):
182182
pane = window.split_window(percent=10)

tests/test_pane.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
import pytest
1111

12-
from libtmux._internal.types import StrPath
1312
from libtmux.common import has_gte_version, has_lt_version, has_lte_version
1413
from libtmux.constants import PaneDirection, ResizeAdjustmentDirection
1514
from libtmux.test.retry import retry_until
1615

1716
if t.TYPE_CHECKING:
17+
from libtmux._internal.types import StrPath
1818
from libtmux.session import Session
1919

2020
logger = logging.getLogger(__name__)
@@ -397,8 +397,8 @@ def test_split_start_directory(
397397
actual_start_directory = start_directory
398398
expected_path = None
399399

400-
if start_directory and str(start_directory) not in ["", "None"]:
401-
if "{user_path}" in str(start_directory):
400+
if start_directory and str(start_directory) not in {"", "None"}:
401+
if f"{user_path}" in str(start_directory):
402402
# Replace placeholder with actual user_path
403403
actual_start_directory = str(start_directory).format(user_path=user_path)
404404
expected_path = str(user_path)
@@ -424,7 +424,8 @@ def test_split_start_directory(
424424

425425

426426
def test_split_start_directory_pathlib(
427-
session: Session, user_path: pathlib.Path
427+
session: Session,
428+
user_path: pathlib.Path,
428429
) -> None:
429430
"""Test Pane.split accepts pathlib.Path for start_directory."""
430431
window = session.new_window(window_name="test_split_pathlib")

tests/test_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import pytest
1313

14-
from libtmux._internal.types import StrPath
1514
from libtmux.common import has_gte_version, has_version
1615
from libtmux.server import Server
1716

1817
if t.TYPE_CHECKING:
18+
from libtmux._internal.types import StrPath
1919
from libtmux.session import Session
2020

2121
logger = logging.getLogger(__name__)
@@ -365,8 +365,8 @@ def test_new_session_start_directory(
365365
actual_start_directory = start_directory
366366
expected_path = None
367367

368-
if start_directory and str(start_directory) not in ["", "None"]:
369-
if "{user_path}" in str(start_directory):
368+
if start_directory and str(start_directory) not in {"", "None"}:
369+
if f"{user_path}" in str(start_directory):
370370
# Replace placeholder with actual user_path
371371
actual_start_directory = str(start_directory).format(user_path=user_path)
372372
expected_path = str(user_path)
@@ -397,7 +397,8 @@ def test_new_session_start_directory(
397397

398398

399399
def test_new_session_start_directory_pathlib(
400-
server: Server, user_path: pathlib.Path
400+
server: Server,
401+
user_path: pathlib.Path,
401402
) -> None:
402403
"""Test Server.new_session accepts pathlib.Path for start_directory."""
403404
# Pass pathlib.Path directly to test pathlib.Path acceptance

tests/test_session.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import pytest
1111

1212
from libtmux import exc
13-
from libtmux._internal.types import StrPath
1413
from libtmux.common import has_gte_version, has_lt_version
1514
from libtmux.constants import WindowDirection
1615
from libtmux.pane import Pane
@@ -20,6 +19,7 @@
2019
from libtmux.window import Window
2120

2221
if t.TYPE_CHECKING:
22+
from libtmux._internal.types import StrPath
2323
from libtmux.server import Server
2424

2525
logger = logging.getLogger(__name__)
@@ -488,8 +488,8 @@ def test_new_window_start_directory(
488488
actual_start_directory = start_directory
489489
expected_path = None
490490

491-
if start_directory and str(start_directory) not in ["", "None"]:
492-
if "{user_path}" in str(start_directory):
491+
if start_directory and str(start_directory) not in {"", "None"}:
492+
if f"{user_path}" in str(start_directory):
493493
# Replace placeholder with actual user_path
494494
actual_start_directory = str(start_directory).format(user_path=user_path)
495495
expected_path = str(user_path)
@@ -520,7 +520,8 @@ def test_new_window_start_directory(
520520

521521

522522
def test_new_window_start_directory_pathlib(
523-
session: Session, user_path: pathlib.Path
523+
session: Session,
524+
user_path: pathlib.Path,
524525
) -> None:
525526
"""Test Session.new_window accepts pathlib.Path for start_directory."""
526527
# Pass pathlib.Path directly to test pathlib.Path acceptance

tests/test_window.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from libtmux import exc
1414
from libtmux._internal.query_list import ObjectDoesNotExist
15-
from libtmux._internal.types import StrPath
1615
from libtmux.common import has_gte_version, has_lt_version, has_lte_version
1716
from libtmux.constants import (
1817
PaneDirection,
@@ -24,6 +23,7 @@
2423
from libtmux.window import Window
2524

2625
if t.TYPE_CHECKING:
26+
from libtmux._internal.types import StrPath
2727
from libtmux.session import Session
2828

2929
logger = logging.getLogger(__name__)
@@ -712,8 +712,8 @@ def test_split_start_directory(
712712
actual_start_directory = start_directory
713713
expected_path = None
714714

715-
if start_directory and str(start_directory) not in ["", "None"]:
716-
if "{user_path}" in str(start_directory):
715+
if start_directory and str(start_directory) not in {"", "None"}:
716+
if f"{user_path}" in str(start_directory):
717717
# Replace placeholder with actual user_path
718718
actual_start_directory = str(start_directory).format(user_path=user_path)
719719
expected_path = str(user_path)
@@ -739,7 +739,8 @@ def test_split_start_directory(
739739

740740

741741
def test_split_start_directory_pathlib(
742-
session: Session, user_path: pathlib.Path
742+
session: Session,
743+
user_path: pathlib.Path,
743744
) -> None:
744745
"""Test Window.split accepts pathlib.Path for start_directory."""
745746
window = session.new_window(window_name="test_window_split_pathlib")

0 commit comments

Comments
 (0)