Skip to content

Commit a72c4e7

Browse files
committed
chore(ruff): Run automated fixes (97 errors)
- conftest.py: 1 × I001 (unsorted-imports) - docs/_ext/aafig.py: 5 × C408 (unnecessary-collection-call) 1 × RUF005 (collection-literal-concatenation) - docs/conf.py: 2 × C408 (unnecessary-collection-call) 1 × I001 (unsorted-imports) 1 × SIM108 (if-else-block-instead-of-if-exp) 1 × RUF100 (unused-noqa) - src/tmuxp/cli/debug_info.py: 1 × I001 (unsorted-imports) 1 × C417 (unnecessary-map) - src/tmuxp/cli/freeze.py: 1 × I001 (unsorted-imports) - src/tmuxp/cli/load.py: 1 × I001 (unsorted-imports) 1 × UP031 (printf-string-formatting) 1 × UP032 (f-string) - src/tmuxp/cli/shell.py: 1 × RUF100 (unused-noqa) - src/tmuxp/cli/utils.py: 1 × UP031 (printf-string-formatting) 1 × UP032 (f-string) - src/tmuxp/exc.py: 1 × UP032 (f-string) - src/tmuxp/shell.py: 4 × RUF100 (unused-noqa) - src/tmuxp/types.py: 1 × RUF100 (unused-noqa) - src/tmuxp/util.py: 2 × RUF100 (unused-noqa) 1 × RUF015 (unnecessary-iterable-allocation-for-first-element) 1 × TRY201 (verbose-raise) - src/tmuxp/workspace/builder.py: 3 × SIM401 (if-else-block-instead-of-dict-get) 1 × F841 (unused-variable) 1 × B006 (mutable-argument-default) 1 × RUF013 (implicit-optional) 1 × TRY201 (verbose-raise) - src/tmuxp/workspace/finders.py: 2 × B006 (mutable-argument-default) 1 × RUF013 (implicit-optional) - src/tmuxp/workspace/freezer.py: 1 × I001 (unsorted-imports) 1 × UP018 (native-literals) - src/tmuxp/workspace/importers.py: 2 × B007 (unused-loop-control-variable) 1 × SIM401 (if-else-block-instead-of-dict-get) - src/tmuxp/workspace/loader.py: 2 × SIM401 (if-else-block-instead-of-dict-get) 1 × UP018 (native-literals) 1 × SIM102 (collapsible-if) - src/tmuxp/workspace/validation.py: 1 × SIM102 (collapsible-if) - tests/cli/test_cli.py: 2 × I001 (unsorted-imports) 2 × SIM105 (suppressible-exception) 1 × PTH201 (path-constructor-current-directory) - tests/cli/test_convert.py: 2 × SIM105 (suppressible-exception) 1 × I001 (unsorted-imports) - tests/cli/test_freeze.py: 2 × I001 (unsorted-imports) 2 × SIM105 (suppressible-exception) 2 × RUF005 (collection-literal-concatenation) - tests/cli/test_import.py: 2 × SIM105 (suppressible-exception) 1 × I001 (unsorted-imports) - tests/cli/test_load.py: 5 × SIM105 (suppressible-exception) 2 × I001 (unsorted-imports) 1 × RUF005 (collection-literal-concatenation) 1 × UP032 (f-string) - tests/cli/test_ls.py: 1 × SIM105 (suppressible-exception) 1 × I001 (unsorted-imports) - tests/cli/test_shell.py: 3 × C408 (unnecessary-collection-call) 2 × I001 (unsorted-imports) 1 × SIM105 (suppressible-exception) - tests/fixtures/__init__.py: 1 × RUF100 (unused-noqa) - tests/fixtures/import_teamocil/__init__.py: 1 × RUF100 (unused-noqa) - tests/fixtures/import_tmuxinator/__init__.py: 1 × RUF100 (unused-noqa) - tests/fixtures/workspace/__init__.py: 1 × RUF100 (unused-noqa) - tests/tests/test_helpers.py: 1 × I001 (unsorted-imports) - tests/workspace/test_builder.py: 1 × I001 (unsorted-imports) 1 × SIM300 (yoda-conditions) 1 × SIM108 (if-else-block-instead-of-if-exp) 1 × UP030 (format-literals) 1 × UP032 (f-string) - tests/workspace/test_config.py: 2 × B007 (unused-loop-control-variable)
1 parent c8f4fa4 commit a72c4e7

32 files changed

+146
-184
lines changed

conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
import typing as t
1111

1212
import pytest
13-
1413
from _pytest.doctest import DoctestItem
15-
1614
from libtmux.test import namer
15+
1716
from tests.fixtures import utils as test_utils
1817
from tmuxp.workspace.finders import get_workspace_dir
1918

docs/_ext/aafig.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
logger = logging.getLogger(__name__)
3030

31-
DEFAULT_FORMATS = dict(html="svg", latex="pdf", text=None)
31+
DEFAULT_FORMATS = {"html": "svg", "latex": "pdf", "text": None}
3232

3333

3434
def merge_dict(dst, src):
@@ -58,21 +58,21 @@ class AafigDirective(images.Image):
5858

5959
has_content = True
6060
required_arguments = 0
61-
own_option_spec = dict(
62-
line_width=float,
63-
background=str,
64-
foreground=str,
65-
fill=str,
66-
aspect=nonnegative_int,
67-
textual=flag,
68-
proportional=flag,
69-
)
61+
own_option_spec = {
62+
"line_width": float,
63+
"background": str,
64+
"foreground": str,
65+
"fill": str,
66+
"aspect": nonnegative_int,
67+
"textual": flag,
68+
"proportional": flag,
69+
}
7070
option_spec = images.Image.option_spec.copy()
7171
option_spec.update(own_option_spec)
7272

7373
def run(self):
74-
aafig_options = dict()
75-
own_options_keys = [self.own_option_spec.keys()] + ["scale"]
74+
aafig_options = {}
75+
own_options_keys = [self.own_option_spec.keys(), "scale"]
7676
for (k, v) in self.options.items():
7777
if k in own_options_keys:
7878
# convert flags to booleans
@@ -88,7 +88,7 @@ def run(self):
8888
if isinstance(image_node, nodes.system_message):
8989
return [image_node]
9090
text = "\n".join(self.content)
91-
image_node.aafig = dict(options=aafig_options, text=text)
91+
image_node.aafig = {"options": aafig_options, "text": text}
9292
return [image_node]
9393

9494

@@ -206,7 +206,7 @@ def setup(app):
206206
app.add_directive("aafig", AafigDirective)
207207
app.connect("doctree-read", render_aafig_images)
208208
app.add_config_value("aafig_format", DEFAULT_FORMATS, "html")
209-
app.add_config_value("aafig_default_options", dict(), "html")
209+
app.add_config_value("aafig_default_options", {}, "html")
210210

211211

212212
# vim: set expandtab shiftwidth=4 softtabstop=4 :

docs/conf.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# flake8: NOQA: E501
22
import contextlib
33
import inspect
4+
import pathlib
45
import sys
56
import typing as t
67
from os.path import relpath
7-
import pathlib
88

99
import tmuxp
1010

@@ -172,12 +172,12 @@
172172
}
173173

174174
# aafig format, try to get working with pdf
175-
aafig_format = dict(latex="pdf", html="gif")
175+
aafig_format = {"latex": "pdf", "html": "gif"}
176176

177-
aafig_default_options = dict(scale=0.75, aspect=0.5, proportional=True)
177+
aafig_default_options = {"scale": 0.75, "aspect": 0.5, "proportional": True}
178178

179179

180-
def linkcode_resolve(domain, info): # NOQA: C901
180+
def linkcode_resolve(domain, info):
181181
"""
182182
Determine the URL corresponding to Python object
183183
@@ -224,10 +224,7 @@ def linkcode_resolve(domain, info): # NOQA: C901
224224
except Exception:
225225
lineno = None
226226

227-
if lineno:
228-
linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
229-
else:
230-
linespec = ""
227+
linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1) if lineno else ""
231228

232229
fn = relpath(fn, start=pathlib.Path(tmuxp.__file__).parent)
233230

src/tmuxp/cli/debug_info.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import typing as t
88

99
from colorama import Fore
10-
1110
from libtmux.__about__ import __version__ as libtmux_version
1211
from libtmux.common import get_version, tmux_cmd
1312

@@ -34,7 +33,7 @@ def prepend_tab(strings):
3433
"""
3534
Prepend tab to strings in list.
3635
"""
37-
return list(map(lambda x: "\t%s" % x, strings))
36+
return ["\t%s" % x for x in strings]
3837

3938
def output_break():
4039
"""

src/tmuxp/cli/freeze.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing as t
66

77
from libtmux.server import Server
8+
89
from tmuxp.config_reader import ConfigReader
910
from tmuxp.exc import TmuxpException
1011
from tmuxp.workspace.finders import get_workspace_dir

src/tmuxp/cli/load.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from libtmux.common import has_gte_version
1717
from libtmux.server import Server
1818
from libtmux.session import Session
19+
1920
from tmuxp.types import StrPath
2021

2122
from .. import config_reader, exc, log, util
@@ -91,9 +92,7 @@ def set_layout_hook(session: Session, hook_name: str) -> None:
9192

9293
# unset the hook immediately after executing
9394
hook_cmd.append(
94-
"set-hook -u -t {target_session} {hook_name}".format(
95-
target_session=session.id, hook_name=hook_name
96-
)
95+
f"set-hook -u -t {session.id} {hook_name}"
9796
)
9897
hook_cmd.append(f"selectw -t {attached_window.id}")
9998

@@ -122,8 +121,7 @@ def load_plugins(session_config: t.Dict[str, t.Any]) -> t.List[t.Any]:
122121
plugins.append(plugin())
123122
except exc.TmuxpPluginException as error:
124123
if not prompt_yes_no(
125-
"%sSkip loading %s?"
126-
% (style(str(error), fg="yellow"), plugin_name),
124+
"{}Skip loading {}?".format(style(str(error), fg="yellow"), plugin_name),
127125
default=True,
128126
):
129127
tmuxp_echo(

src/tmuxp/cli/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def command_shell(
166166
session=session, window_name=args.window_name, current_pane=current_pane
167167
)
168168

169-
pane = util.get_pane(window=window, current_pane=current_pane) # NOQA: F841
169+
pane = util.get_pane(window=window, current_pane=current_pane)
170170

171171
if args.command is not None:
172172
exec(args.command)

src/tmuxp/cli/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def prompt_choices(
126126
if isinstance(choice, str):
127127
options.append(choice)
128128
elif isinstance(choice, tuple):
129-
options.append("%s [%s]" % (choice, choice[0]))
129+
options.append(f"{choice} [{choice[0]}]")
130130
choice = choice[0]
131131
_choices.append(choice)
132132

src/tmuxp/exc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def __init__(
5050
self.cmd = cmd
5151
self.output = output
5252
self.message = (
53-
"before_script failed with returncode {returncode}.\n"
54-
"command: {cmd}\n"
53+
f"before_script failed with returncode {self.returncode}.\n"
54+
f"command: {self.cmd}\n"
5555
"Error output:\n"
56-
"{output}"
57-
).format(returncode=self.returncode, cmd=self.cmd, output=self.output)
56+
f"{self.output}"
57+
)
5858

5959
def __str__(self):
6060
return self.message

src/tmuxp/shell.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def has_ipython() -> bool:
3232

3333
def has_ptpython() -> bool:
3434
try:
35-
from ptpython.repl import embed, run_config # NOQA F841
35+
from ptpython.repl import embed, run_config # F841
3636
except ImportError:
3737
try:
3838
from prompt_toolkit.contrib.repl import embed, run_config # NOQA F841
@@ -44,8 +44,8 @@ def has_ptpython() -> bool:
4444

4545
def has_ptipython() -> bool:
4646
try:
47-
from ptpython.ipython import embed # NOQA F841
48-
from ptpython.repl import run_config # NOQA F841
47+
from ptpython.ipython import embed # F841
48+
from ptpython.repl import run_config # F841
4949
except ImportError:
5050
try:
5151
from prompt_toolkit.contrib.ipython import embed # NOQA F841
@@ -80,7 +80,7 @@ def get_bpython(options, extra_args=None):
8080
if extra_args is None:
8181
extra_args = {}
8282

83-
from bpython import embed # NOQA F841
83+
from bpython import embed # F841
8484

8585
def launch_bpython():
8686
imported_objects = get_launch_args(**options)

0 commit comments

Comments
 (0)