Skip to content

Commit 235d518

Browse files
committed
chore: Aggressive ruff fixes
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes --ignore T201; ruff format . Fixed 23 errors: - docs/_ext/aafig.py: 2 × COM812 (missing-trailing-comma) - src/tmuxp/cli/load.py: 1 × PLR5501 (collapsible-else-if) - src/tmuxp/plugin.py: 3 × FURB110 (if-exp-instead-of-or-operator) - src/tmuxp/shell.py: 6 × PGH004 (blanket-noqa) 6 × RUF100 (unused-noqa) - src/tmuxp/util.py: 1 × PGH004 (blanket-noqa) - src/tmuxp/workspace/builder.py: 2 × COM812 (missing-trailing-comma) - tests/workspace/test_builder.py: 2 × PT014 (pytest-duplicate-parametrize-test-cases)
1 parent 4b5518f commit 235d518

File tree

7 files changed

+19
-49
lines changed

7 files changed

+19
-49
lines changed

docs/_ext/aafig.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def render_aafigure(
193193
try:
194194
try:
195195
with open(
196-
metadata_fname, encoding=locale.getpreferredencoding(False)
196+
metadata_fname,
197+
encoding=locale.getpreferredencoding(False),
197198
) as f:
198199
extra = f.read()
199200
except Exception as e:
@@ -217,7 +218,9 @@ def render_aafigure(
217218
if options["format"].lower() == "svg":
218219
extra = visitor.get_size_attrs()
219220
with open(
220-
metadata_fname, "w", encoding=locale.getpreferredencoding(False)
221+
metadata_fname,
222+
"w",
223+
encoding=locale.getpreferredencoding(False),
221224
) as f:
222225
f.write(extra)
223226

src/tmuxp/cli/load.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ def _load_attached(builder: WorkspaceBuilder, detached: bool) -> None:
143143
builder.session.switch_client() # switch client to new session
144144

145145
os.environ["TMUX"] = tmux_env # set TMUX back again
146-
else:
147-
if not detached:
148-
builder.session.attach_session()
146+
elif not detached:
147+
builder.session.attach_session()
149148

150149

151150
def _load_detached(builder: WorkspaceBuilder) -> None:

src/tmuxp/plugin.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,19 @@ def __init__(self, **kwargs: "Unpack[PluginConfigSchema]") -> None:
157157
"version": self.tmux_version,
158158
"vmin": config["tmux_min_version"],
159159
"vmax": config["tmux_max_version"],
160-
"incompatible": config["tmux_version_incompatible"]
161-
if config["tmux_version_incompatible"]
162-
else [],
160+
"incompatible": config["tmux_version_incompatible"] or [],
163161
},
164162
"libtmux": {
165163
"version": self.libtmux_version,
166164
"vmin": config["libtmux_min_version"],
167165
"vmax": config["libtmux_max_version"],
168-
"incompatible": config["libtmux_version_incompatible"]
169-
if config["libtmux_version_incompatible"]
170-
else [],
166+
"incompatible": config["libtmux_version_incompatible"] or [],
171167
},
172168
"tmuxp": {
173169
"version": self.tmuxp_version,
174170
"vmin": config["tmuxp_min_version"],
175171
"vmax": config["tmuxp_max_version"],
176-
"incompatible": config["tmuxp_version_incompatible"]
177-
if config["tmuxp_version_incompatible"]
178-
else [],
172+
"incompatible": config["tmuxp_version_incompatible"] or [],
179173
},
180174
}
181175

src/tmuxp/shell.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class LaunchImports(t.TypedDict):
5151
def has_ipython() -> bool:
5252
"""Return True if ipython is installed."""
5353
try:
54-
from IPython import start_ipython # NOQA F841
54+
from IPython import start_ipython
5555
except ImportError:
5656
try:
57-
from IPython.Shell import IPShell # NOQA F841
57+
from IPython.Shell import IPShell
5858
except ImportError:
5959
return False
6060

@@ -67,7 +67,7 @@ def has_ptpython() -> bool:
6767
from ptpython.repl import embed, run_config # F841
6868
except ImportError:
6969
try:
70-
from prompt_toolkit.contrib.repl import embed, run_config # NOQA F841
70+
from prompt_toolkit.contrib.repl import embed, run_config
7171
except ImportError:
7272
return False
7373

@@ -81,8 +81,8 @@ def has_ptipython() -> bool:
8181
from ptpython.repl import run_config # F841
8282
except ImportError:
8383
try:
84-
from prompt_toolkit.contrib.ipython import embed # NOQA F841
85-
from prompt_toolkit.contrib.repl import run_config # NOQA F841
84+
from prompt_toolkit.contrib.ipython import embed
85+
from prompt_toolkit.contrib.repl import run_config
8686
except ImportError:
8787
return False
8888

@@ -92,7 +92,7 @@ def has_ptipython() -> bool:
9292
def has_bpython() -> bool:
9393
"""Return True if bpython is installed."""
9494
try:
95-
from bpython import embed # NOQA F841
95+
from bpython import embed
9696
except ImportError:
9797
return False
9898
return True

src/tmuxp/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def oh_my_zsh_auto_title() -> None:
6969
if (
7070
"SHELL" in os.environ
7171
and "zsh" in os.environ.get("SHELL", "")
72-
and os.path.exists(os.path.expanduser("~/.oh-my-zsh")) # NOQA PTH110, PTH111
72+
and os.path.exists(os.path.expanduser("~/.oh-my-zsh")) # NOQA: PTH110, PTH111
7373
and (
7474
"DISABLE_AUTO_TITLE" not in os.environ
7575
or os.environ.get("DISABLE_AUTO_TITLE") == "false"

src/tmuxp/workspace/builder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
def get_default_columns() -> int:
2525
"""Return default session column size use when building new tmux sessions."""
2626
return int(
27-
os.getenv("TMUXP_DEFAULT_COLUMNS", os.getenv("COLUMNS", COLUMNS_FALLBACK))
27+
os.getenv("TMUXP_DEFAULT_COLUMNS", os.getenv("COLUMNS", COLUMNS_FALLBACK)),
2828
)
2929

3030

@@ -250,7 +250,7 @@ def build(self, session: t.Optional[Session] = None, append: bool = False) -> No
250250
and os.getenv("TMUXP_DETECT_TERMINAL_SIZE", "1") == "1"
251251
):
252252
terminal_size = shutil.get_terminal_size(
253-
fallback=(get_default_columns(), get_default_rows())
253+
fallback=(get_default_columns(), get_default_rows()),
254254
)
255255
new_session_kwargs["x"] = terminal_size.columns
256256
new_session_kwargs["y"] = terminal_size.lines

tests/workspace/test_builder.py

-26
Original file line numberDiff line numberDiff line change
@@ -1169,32 +1169,6 @@ def test_find_current_active_pane(
11691169
(
11701170
textwrap.dedent(
11711171
"""
1172-
session_name: Should not execute
1173-
windows:
1174-
- panes:
1175-
- shell_command:
1176-
- cmd: echo "___$((1 + 3))___"
1177-
enter: false
1178-
""",
1179-
),
1180-
"___4___",
1181-
False,
1182-
),
1183-
(
1184-
textwrap.dedent(
1185-
"""
1186-
session_name: Should execute
1187-
windows:
1188-
- panes:
1189-
- shell_command: echo "___$((1 + 3))___"
1190-
""",
1191-
),
1192-
"___4___",
1193-
True,
1194-
),
1195-
(
1196-
textwrap.dedent(
1197-
"""
11981172
session_name: Should execute
11991173
windows:
12001174
- panes:

0 commit comments

Comments
 (0)