Skip to content

Commit

Permalink
Aggressive ruff fixes
Browse files Browse the repository at this point in the history
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes --ignore T201 --ignore F401 --ignore PT014 --ignore RUF100 --ignore PGH004; ruff format .

Fixed 8 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/workspace/builder.py:
    2 × COM812 (missing-trailing-comma)

Found 1243 errors (8 fixed, 1235 remaining).
  • Loading branch information
tony committed Apr 13, 2024
1 parent 4b5518f commit 85b982d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
7 changes: 5 additions & 2 deletions docs/_ext/aafig.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def render_aafigure(
try:
try:
with open(
metadata_fname, encoding=locale.getpreferredencoding(False)
metadata_fname,
encoding=locale.getpreferredencoding(False),
) as f:
extra = f.read()
except Exception as e:
Expand All @@ -217,7 +218,9 @@ def render_aafigure(
if options["format"].lower() == "svg":
extra = visitor.get_size_attrs()
with open(
metadata_fname, "w", encoding=locale.getpreferredencoding(False)
metadata_fname,
"w",
encoding=locale.getpreferredencoding(False),
) as f:
f.write(extra)

Expand Down
5 changes: 2 additions & 3 deletions src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ def _load_attached(builder: WorkspaceBuilder, detached: bool) -> None:
builder.session.switch_client() # switch client to new session

os.environ["TMUX"] = tmux_env # set TMUX back again
else:
if not detached:
builder.session.attach_session()
elif not detached:
builder.session.attach_session()


def _load_detached(builder: WorkspaceBuilder) -> None:
Expand Down
12 changes: 3 additions & 9 deletions src/tmuxp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,19 @@ def __init__(self, **kwargs: "Unpack[PluginConfigSchema]") -> None:
"version": self.tmux_version,
"vmin": config["tmux_min_version"],
"vmax": config["tmux_max_version"],
"incompatible": config["tmux_version_incompatible"]
if config["tmux_version_incompatible"]
else [],
"incompatible": config["tmux_version_incompatible"] or [],
},
"libtmux": {
"version": self.libtmux_version,
"vmin": config["libtmux_min_version"],
"vmax": config["libtmux_max_version"],
"incompatible": config["libtmux_version_incompatible"]
if config["libtmux_version_incompatible"]
else [],
"incompatible": config["libtmux_version_incompatible"] or [],
},
"tmuxp": {
"version": self.tmuxp_version,
"vmin": config["tmuxp_min_version"],
"vmax": config["tmuxp_max_version"],
"incompatible": config["tmuxp_version_incompatible"]
if config["tmuxp_version_incompatible"]
else [],
"incompatible": config["tmuxp_version_incompatible"] or [],
},
}

Expand Down
4 changes: 2 additions & 2 deletions src/tmuxp/workspace/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def get_default_columns() -> int:
"""Return default session column size use when building new tmux sessions."""
return int(
os.getenv("TMUXP_DEFAULT_COLUMNS", os.getenv("COLUMNS", COLUMNS_FALLBACK))
os.getenv("TMUXP_DEFAULT_COLUMNS", os.getenv("COLUMNS", COLUMNS_FALLBACK)),
)


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

0 comments on commit 85b982d

Please sign in to comment.