Skip to content

Commit a1dd7b1

Browse files
committed
ruff format (after adding flake8-commas)
1 parent a7153a2 commit a1dd7b1

20 files changed

+114
-41
lines changed

src/libtmux/_internal/query_list.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def keygetter(
6666

6767

6868
def parse_lookup(
69-
obj: "Mapping[str, t.Any]", path: str, lookup: str,
69+
obj: "Mapping[str, t.Any]",
70+
path: str,
71+
lookup: str,
7072
) -> t.Optional[t.Any]:
7173
"""Check if field lookup key, e.g. "my__path__contains" has comparator, return val.
7274

src/libtmux/_vendor/version.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@
3333
],
3434
]
3535
CmpKey = Tuple[
36-
int, Tuple[int, ...], PrePostDevType, PrePostDevType, PrePostDevType, LocalType,
36+
int,
37+
Tuple[int, ...],
38+
PrePostDevType,
39+
PrePostDevType,
40+
PrePostDevType,
41+
LocalType,
3742
]
3843
VersionComparisonMethod = Callable[[CmpKey, CmpKey], bool]
3944

4045
_Version = collections.namedtuple(
41-
"_Version", ["epoch", "release", "dev", "pre", "post", "local"],
46+
"_Version",
47+
["epoch", "release", "dev", "pre", "post", "local"],
4248
)
4349

4450

@@ -220,7 +226,8 @@ def __init__(self, version: str) -> None:
220226
release=tuple(int(i) for i in match.group("release").split(".")),
221227
pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")),
222228
post=_parse_letter_version(
223-
match.group("post_l"), match.group("post_n1") or match.group("post_n2"),
229+
match.group("post_l"),
230+
match.group("post_n1") or match.group("post_n2"),
224231
),
225232
dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")),
226233
local=_parse_local_version(match.group("local")),
@@ -468,7 +475,8 @@ def micro(self) -> int:
468475

469476

470477
def _parse_letter_version(
471-
letter: str, number: Union[str, bytes, SupportsInt],
478+
letter: str,
479+
number: Union[str, bytes, SupportsInt],
472480
) -> Optional[Tuple[str, int]]:
473481
if letter:
474482
# We consider there to be an implicit 0 in a pre-release if there is

src/libtmux/common.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
231231

232232
try:
233233
self.process = subprocess.Popen(
234-
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
234+
cmd,
235+
stdout=subprocess.PIPE,
236+
stderr=subprocess.PIPE,
235237
)
236238
stdout, stderr = self.process.communicate()
237239
returncode = self.process.returncode
@@ -258,7 +260,8 @@ def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
258260

259261
logger.debug(
260262
"self.stdout for {cmd}: {stdout}".format(
261-
cmd=" ".join(cmd), stdout=self.stdout,
263+
cmd=" ".join(cmd),
264+
stdout=self.stdout,
262265
),
263266
)
264267

@@ -419,7 +422,8 @@ def has_minimum_version(raises: bool = True) -> bool:
419422
raise exc.VersionTooLow(
420423
"libtmux only supports tmux {} and greater. This system"
421424
" has {} installed. Upgrade your tmux to use libtmux.".format(
422-
TMUX_MIN_VERSION, get_version(),
425+
TMUX_MIN_VERSION,
426+
get_version(),
423427
),
424428
)
425429
else:

src/libtmux/exc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class BadSessionName(LibTmuxException):
5151
"""Disallowed session name for tmux (empty, contains periods or colons)."""
5252

5353
def __init__(
54-
self, reason: str, session_name: t.Optional[str] = None, *args: object,
54+
self,
55+
reason: str,
56+
session_name: t.Optional[str] = None,
57+
*args: object,
5558
):
5659
msg = f"Bad session name: {reason}"
5760
if session_name is not None:

src/libtmux/neo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ def _refresh(
170170
) -> None:
171171
assert isinstance(obj_id, str)
172172
obj = fetch_obj(
173-
obj_key=obj_key, obj_id=obj_id, list_cmd=list_cmd, server=self.server,
173+
obj_key=obj_key,
174+
obj_id=obj_id,
175+
list_cmd=list_cmd,
176+
server=self.server,
174177
)
175178
assert obj is not None
176179
if obj is not None:
@@ -233,7 +236,9 @@ def fetch_obj(
233236
) -> OutputRaw:
234237
"""Fetch raw data from tmux command."""
235238
obj_formatters_filtered = fetch_objs(
236-
server=server, list_cmd=list_cmd, list_extra_args=list_extra_args,
239+
server=server,
240+
list_cmd=list_cmd,
241+
list_extra_args=list_extra_args,
237242
)
238243

239244
obj = None

src/libtmux/pane.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ def send_keys(
245245

246246
@overload
247247
def display_message(
248-
self, cmd: str, get_text: "t.Literal[True]",
248+
self,
249+
cmd: str,
250+
get_text: "t.Literal[True]",
249251
) -> t.Union[str, t.List[str]]:
250252
...
251253

@@ -254,7 +256,9 @@ def display_message(self, cmd: str, get_text: "t.Literal[False]") -> None:
254256
...
255257

256258
def display_message(
257-
self, cmd: str, get_text: bool = False,
259+
self,
260+
cmd: str,
261+
get_text: bool = False,
258262
) -> t.Optional[t.Union[str, t.List[str]]]:
259263
"""Display message to pane.
260264

src/libtmux/pytest_plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def session_params() -> t.Dict[str, t.Any]:
185185

186186
@pytest.fixture(scope="function")
187187
def session(
188-
request: pytest.FixtureRequest, session_params: t.Dict[str, t.Any], server: Server,
188+
request: pytest.FixtureRequest,
189+
session_params: t.Dict[str, t.Any],
190+
server: Server,
189191
) -> "Session":
190192
"""Return new, temporary :class:`libtmux.Session`.
191193

src/libtmux/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ def new_session(
490490
)
491491

492492
return Session.from_session_id(
493-
server=self, session_id=session_formatters["session_id"],
493+
server=self,
494+
session_id=session_formatters["session_id"],
494495
)
495496

496497
#

src/libtmux/session.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def refresh(self) -> None:
7777
"""Refresh session attributes from tmux."""
7878
assert isinstance(self.session_id, str)
7979
return super()._refresh(
80-
obj_key="session_id", obj_id=self.session_id, list_cmd="list-sessions",
80+
obj_key="session_id",
81+
obj_id=self.session_id,
82+
list_cmd="list-sessions",
8183
)
8284

8385
@classmethod
@@ -169,7 +171,10 @@ def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
169171
"""
170172

171173
def set_option(
172-
self, option: str, value: t.Union[str, int], _global: bool = False,
174+
self,
175+
option: str,
176+
value: t.Union[str, int],
177+
_global: bool = False,
173178
) -> "Session":
174179
"""Set option ``$ tmux set-option <option> <value>``.
175180
@@ -220,7 +225,8 @@ def set_option(
220225
return self
221226

222227
def show_options(
223-
self, _global: t.Optional[bool] = False,
228+
self,
229+
_global: t.Optional[bool] = False,
224230
) -> t.Dict[str, t.Union[str, int]]:
225231
"""Return dict of options for the session.
226232
@@ -258,7 +264,9 @@ def show_options(
258264
return session_options
259265

260266
def show_option(
261-
self, option: str, _global: bool = False,
267+
self,
268+
option: str,
269+
_global: bool = False,
262270
) -> t.Optional[t.Union[str, int, bool]]:
263271
"""Return option value for the target session.
264272
@@ -506,7 +514,8 @@ def new_window(
506514
)
507515

508516
return Window.from_window_id(
509-
server=self.server, window_id=window_formatters["window_id"],
517+
server=self.server,
518+
window_id=window_formatters["window_id"],
510519
)
511520

512521
def kill_window(self, target_window: t.Optional[str] = None) -> None:
@@ -604,7 +613,8 @@ def __getitem__(self, key: str) -> t.Any:
604613
605614
"""
606615
warnings.warn(
607-
f"Item lookups, e.g. session['{key}'] is deprecated", stacklevel=2,
616+
f"Item lookups, e.g. session['{key}'] is deprecated",
617+
stacklevel=2,
608618
)
609619
return getattr(self, key)
610620

src/libtmux/test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class RandomStrSequence:
2828
"""Factory to generate random string."""
2929

3030
def __init__(
31-
self, characters: str = "abcdefghijklmnopqrstuvwxyz0123456789_",
31+
self,
32+
characters: str = "abcdefghijklmnopqrstuvwxyz0123456789_",
3233
) -> None:
3334
"""Create a random letter / number generator. 8 chars in length.
3435
@@ -141,7 +142,8 @@ def get_test_session_name(server: "Server", prefix: str = TEST_SESSION_PREFIX) -
141142

142143

143144
def get_test_window_name(
144-
session: "Session", prefix: t.Optional[str] = TEST_SESSION_PREFIX,
145+
session: "Session",
146+
prefix: t.Optional[str] = TEST_SESSION_PREFIX,
145147
) -> str:
146148
"""
147149
Faker to create a window name that doesn't exist.
@@ -180,7 +182,9 @@ def get_test_window_name(
180182

181183
@contextlib.contextmanager
182184
def temp_session(
183-
server: Server, *args: t.Any, **kwargs: t.Any,
185+
server: Server,
186+
*args: t.Any,
187+
**kwargs: t.Any,
184188
) -> t.Generator["Session", t.Any, t.Any]:
185189
"""
186190
Return a context manager with a temporary session.
@@ -230,7 +234,9 @@ def temp_session(
230234

231235
@contextlib.contextmanager
232236
def temp_window(
233-
session: "Session", *args: t.Any, **kwargs: t.Any,
237+
session: "Session",
238+
*args: t.Any,
239+
**kwargs: t.Any,
234240
) -> t.Generator["Window", t.Any, t.Any]:
235241
"""
236242
Return a context manager with a temporary window.

src/libtmux/window.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict"
399399
return window_options
400400

401401
def show_window_option(
402-
self, option: str, g: bool = False,
402+
self,
403+
option: str,
404+
g: bool = False,
403405
) -> t.Optional[t.Union[str, int]]:
404406
"""Return option value for the target window.
405407
@@ -486,7 +488,9 @@ def kill_window(self) -> None:
486488
raise exc.LibTmuxException(proc.stderr)
487489

488490
def move_window(
489-
self, destination: str = "", session: t.Optional[str] = None,
491+
self,
492+
destination: str = "",
493+
session: t.Optional[str] = None,
490494
) -> "Window":
491495
"""Move current :class:`Window` object ``$ tmux move-window``.
492496

tests/legacy_api/test_common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ class SessionCheckName(t.NamedTuple):
215215
],
216216
)
217217
def test_session_check_name(
218-
session_name: t.Optional[str], raises: bool, exc_msg_regex: t.Optional[str],
218+
session_name: t.Optional[str],
219+
raises: bool,
220+
exc_msg_regex: t.Optional[str],
219221
) -> None:
220222
"""Verify session_check_name()."""
221223
if raises:

tests/legacy_api/test_pane.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def test_capture_pane(session: Session) -> None:
8383
pane_contents = "\n".join(pane.capture_pane())
8484
assert pane_contents == "$"
8585
pane.send_keys(
86-
r'printf "\n%s\n" "Hello World !"', literal=True, suppress_history=False,
86+
r'printf "\n%s\n" "Hello World !"',
87+
literal=True,
88+
suppress_history=False,
8789
)
8890
pane_contents = "\n".join(pane.capture_pane())
8991
assert pane_contents == r'$ printf "\n%s\n" "Hello World !"{}'.format(

tests/legacy_api/test_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ def test_unset_environment(session: Session) -> None:
220220
[("hey.period", True), ("hey:its a colon", True), ("hey moo", False)],
221221
)
222222
def test_periods_raise_badsessionname(
223-
server: Server, session: Session, session_name: str, raises: bool,
223+
server: Server,
224+
session: Session,
225+
session_name: str,
226+
raises: bool,
224227
) -> None:
225228
"""Verify session names with periods raise BadSessionName."""
226229
new_name = session_name + "moo" # used for rename / switch

tests/legacy_api/test_window.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ def test_split_window_horizontal(session: Session) -> None:
162162
[("test", "ha ha ha fjewlkjflwef"), ("test", "hello \\ wazzup 0")],
163163
)
164164
def test_window_rename(
165-
session: Session, window_name_before: str, window_name_after: str,
165+
session: Session,
166+
window_name_before: str,
167+
window_name_after: str,
166168
) -> None:
167169
"""Test Window.rename_window()."""
168170
window_name_before = "test"
@@ -308,7 +310,8 @@ def test_select_layout_accepts_no_arg(server: Server, session: Session) -> None:
308310

309311

310312
@pytest.mark.skipif(
311-
has_lt_version("3.2"), reason="needs filter introduced in tmux >= 3.2",
313+
has_lt_version("3.2"),
314+
reason="needs filter introduced in tmux >= 3.2",
312315
)
313316
def test_empty_window_name(session: Session) -> None:
314317
"""New windows can be created with empty string for window name."""

tests/test_common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ class SessionCheckName(t.NamedTuple):
215215
],
216216
)
217217
def test_session_check_name(
218-
session_name: t.Optional[str], raises: bool, exc_msg_regex: t.Optional[str],
218+
session_name: t.Optional[str],
219+
raises: bool,
220+
exc_msg_regex: t.Optional[str],
219221
) -> None:
220222
"""Verify session_check_name()."""
221223
if raises:

tests/test_pane.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def test_capture_pane(session: Session) -> None:
8787
pane_contents = "\n".join(pane.capture_pane())
8888
assert pane_contents == "$"
8989
pane.send_keys(
90-
r'printf "\n%s\n" "Hello World !"', literal=True, suppress_history=False,
90+
r'printf "\n%s\n" "Hello World !"',
91+
literal=True,
92+
suppress_history=False,
9193
)
9294
pane_contents = "\n".join(pane.capture_pane())
9395
assert pane_contents == r'$ printf "\n%s\n" "Hello World !"{}'.format(

tests/test_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ class PeriodRaisesBadSessionName(t.NamedTuple):
231231
],
232232
)
233233
def test_periods_raise_bad_session_name(
234-
server: Server, session: Session, session_name: str, raises: bool,
234+
server: Server,
235+
session: Session,
236+
session_name: str,
237+
raises: bool,
235238
) -> None:
236239
"""Verify session names with periods raise BadSessionName."""
237240
new_name = session_name + "moo" # used for rename / switch

0 commit comments

Comments
 (0)