From dc41d3f98a5ba35b3586efc12cb93c8a308c075e Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 9 Jan 2025 17:24:54 -0600 Subject: [PATCH] chore: Format with ruff 0.9.0 See also: https://github.com/astral-sh/ruff/blob/0.9.0/CHANGELOG.md#090 --- docs/conf.py | 2 +- src/libtmux/exc.py | 2 +- src/libtmux/pane.py | 4 ++-- src/libtmux/session.py | 2 +- tests/legacy_api/test_common.py | 12 ++++++------ tests/legacy_api/test_session.py | 6 +++--- tests/legacy_api/test_window.py | 6 +++--- tests/test_common.py | 12 ++++++------ tests/test_session.py | 12 ++++++------ tests/test_window.py | 18 +++++++++--------- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fb1d2359e..ead126d71 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -106,7 +106,7 @@ } # linkify_issues -issue_url_tpl = f'{about["__github__"]}/issues/{{issue_id}}' +issue_url_tpl = f"{about['__github__']}/issues/{{issue_id}}" # sphinx.ext.autodoc autoclass_content = "both" diff --git a/src/libtmux/exc.py b/src/libtmux/exc.py index 430f17b53..7777403f3 100644 --- a/src/libtmux/exc.py +++ b/src/libtmux/exc.py @@ -41,7 +41,7 @@ def __init__( if all(arg is not None for arg in [obj_key, obj_id, list_cmd, list_extra_args]): return super().__init__( f"Could not find {obj_key}={obj_id} for {list_cmd} " - f'{list_extra_args if list_extra_args is not None else ""}', + f"{list_extra_args if list_extra_args is not None else ''}", ) return super().__init__("Could not find object") diff --git a/src/libtmux/pane.py b/src/libtmux/pane.py index 684a6eba5..76208c61f 100644 --- a/src/libtmux/pane.py +++ b/src/libtmux/pane.py @@ -604,7 +604,7 @@ def split( if size is not None: if has_lt_version("3.1"): if isinstance(size, str) and size.endswith("%"): - tmux_args += (f'-p{str(size).rstrip("%")}',) + tmux_args += (f"-p{str(size).rstrip('%')}",) else: warnings.warn( 'Ignored size. Use percent in tmux < 3.1, e.g. "size=50%"', @@ -857,7 +857,7 @@ def split_window( stacklevel=2, ) if size is None and percent is not None: - size = f'{str(percent).rstrip("%")}%' + size = f"{str(percent).rstrip('%')}%" return self.split( target=target, attach=attach, diff --git a/src/libtmux/session.py b/src/libtmux/session.py index c7eaceec1..1b1fc260d 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -414,7 +414,7 @@ def attach( flags += ("-x",) if flags_ is not None and isinstance(flags_, list): - flags += tuple(f'{",".join(flags_)}') + flags += tuple(f"{','.join(flags_)}") proc = self.cmd( "attach-session", diff --git a/tests/legacy_api/test_common.py b/tests/legacy_api/test_common.py index e31fe99cb..fb32427e0 100644 --- a/tests/legacy_api/test_common.py +++ b/tests/legacy_api/test_common.py @@ -47,9 +47,9 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi: assert has_minimum_version() assert has_gte_version(TMUX_MIN_VERSION) assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version" - assert ( - get_version() == f"{TMUX_MAX_VERSION}-master" - ), "Is the latest supported version with -master appended" + assert get_version() == f"{TMUX_MAX_VERSION}-master", ( + "Is the latest supported version with -master appended" + ) def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None: @@ -85,9 +85,9 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi: assert has_minimum_version() assert has_gte_version(TMUX_MIN_VERSION) assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version" - assert ( - get_version() == f"{TMUX_MAX_VERSION}-openbsd" - ), "Is the latest supported version with -openbsd appended" + assert get_version() == f"{TMUX_MAX_VERSION}-openbsd", ( + "Is the latest supported version with -openbsd appended" + ) def test_get_version_too_low(monkeypatch: pytest.MonkeyPatch) -> None: diff --git a/tests/legacy_api/test_session.py b/tests/legacy_api/test_session.py index ef8be39bd..ffe115ae2 100644 --- a/tests/legacy_api/test_session.py +++ b/tests/legacy_api/test_session.py @@ -314,6 +314,6 @@ def test_new_window_with_environment_logs_warning_for_old_tmux( environment={"ENV_VAR": "window"}, ) - assert any( - "Environment flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Environment flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) diff --git a/tests/legacy_api/test_window.py b/tests/legacy_api/test_window.py index 807abbac4..23668f45c 100644 --- a/tests/legacy_api/test_window.py +++ b/tests/legacy_api/test_window.py @@ -439,6 +439,6 @@ def test_split_window_with_environment_logs_warning_for_old_tmux( environment={"ENV_VAR": "pane"}, ) - assert any( - "Environment flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Environment flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) diff --git a/tests/test_common.py b/tests/test_common.py index e31fe99cb..fb32427e0 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -47,9 +47,9 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi: assert has_minimum_version() assert has_gte_version(TMUX_MIN_VERSION) assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version" - assert ( - get_version() == f"{TMUX_MAX_VERSION}-master" - ), "Is the latest supported version with -master appended" + assert get_version() == f"{TMUX_MAX_VERSION}-master", ( + "Is the latest supported version with -master appended" + ) def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None: @@ -85,9 +85,9 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi: assert has_minimum_version() assert has_gte_version(TMUX_MIN_VERSION) assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version" - assert ( - get_version() == f"{TMUX_MAX_VERSION}-openbsd" - ), "Is the latest supported version with -openbsd appended" + assert get_version() == f"{TMUX_MAX_VERSION}-openbsd", ( + "Is the latest supported version with -openbsd appended" + ) def test_get_version_too_low(monkeypatch: pytest.MonkeyPatch) -> None: diff --git a/tests/test_session.py b/tests/test_session.py index 9228b613e..bd398a06c 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -326,9 +326,9 @@ def test_new_window_with_environment_logs_warning_for_old_tmux( environment={"ENV_VAR": "window"}, ) - assert any( - "Environment flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Environment flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) @pytest.mark.skipif( @@ -378,6 +378,6 @@ def test_session_new_window_with_direction_logs_warning_for_old_tmux( direction=WindowDirection.After, ) - assert any( - "Direction flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Direction flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) diff --git a/tests/test_window.py b/tests/test_window.py index b0fcdbda3..767f500ea 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -461,9 +461,9 @@ def test_split_with_environment_logs_warning_for_old_tmux( environment={"ENV_VAR": "pane"}, ) - assert any( - "Environment flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Environment flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) @pytest.mark.skipif( @@ -596,10 +596,10 @@ def test_new_window_with_direction_logs_warning_for_old_tmux( direction=WindowDirection.After, ) - assert any( - "Window target ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Window target ignored" in record.msg for record in caplog.records), ( + "Warning missing" + ) - assert any( - "Direction flag ignored" in record.msg for record in caplog.records - ), "Warning missing" + assert any("Direction flag ignored" in record.msg for record in caplog.records), ( + "Warning missing" + )