Skip to content

Commit 0abcbca

Browse files
committed
chore(ruff): Linting fixes
docs/conf.py:80:89: E501 Line too long (100 > 88 characters) docs/conf.py:81:89: E501 Line too long (628 > 88 characters) docs/conf.py:90:88: E501 Line too long (167 > 88 characters) src/libtmux/common.py:14:26: F401 [*] `typing.Generic` imported but unused src/libtmux/common.py:14:35: F401 [*] `typing.KeysView` imported but unused src/libtmux/common.py:14:45: F401 [*] `typing.List` imported but unused src/libtmux/common.py:14:61: F401 [*] `typing.TypeVar` imported but unused src/libtmux/common.py:14:77: F401 [*] `typing.overload` imported but unused src/libtmux/common.py:20:35: F401 [*] `typing_extensions.Literal` imported but unused src/libtmux/common.py:22:30: F401 [*] `libtmux.pane.Pane` imported but unused src/libtmux/common.py:23:33: F401 [*] `libtmux.session.Session` imported but unused src/libtmux/common.py:24:32: F401 [*] `libtmux.window.Window` imported but unused src/libtmux/common.py:76:13: F841 [*] Local variable `stderr` is assigned to but never used src/libtmux/common.py:100:13: F841 [*] Local variable `stderr` is assigned to but never used src/libtmux/common.py:123:13: F841 [*] Local variable `stderr` is assigned to but never used src/libtmux/common.py:151:20: F823 Local variable `t` referenced before assignment src/libtmux/common.py:152:13: F402 Import `t` from line 13 shadowed by loop variable src/libtmux/common.py:179:20: F823 Local variable `t` referenced before assignment src/libtmux/common.py:189:13: F402 Import `t` from line 13 shadowed by loop variable src/libtmux/pane.py:17:20: F401 [*] `.formats` imported but unused src/libtmux/pane.py:18:21: F401 [*] `.common.PaneDict` imported but unused Found 21 errors.
1 parent 9f7e93e commit 0abcbca

File tree

3 files changed

+34
-40
lines changed

3 files changed

+34
-40
lines changed

docs/conf.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# flake8: NOQA E5
1+
# flake8: NOQA: E501
2+
import contextlib
23
import inspect
34
import sys
4-
from os.path import dirname, relpath
5-
from pathlib import Path
5+
from os.path import relpath
6+
import pathlib
67
import typing as t
78

89
import libtmux # NOQA
@@ -12,7 +13,7 @@
1213
from sphinx.application import Sphinx
1314

1415
# Get the project root dir, which is the parent dir of this
15-
cwd = Path(__file__).parent
16+
cwd = pathlib.Path(__file__).parent
1617
project_root = cwd.parent
1718
project_src = project_root / "src"
1819

@@ -21,7 +22,7 @@
2122

2223
# package data
2324
about: t.Dict[str, str] = {}
24-
with open(project_src / "libtmux" / "__about__.py") as fp:
25+
with (project_src / "libtmux" / "__about__.py").open() as fp:
2526
exec(fp.read(), about)
2627

2728
extensions = [
@@ -125,13 +126,13 @@
125126
ogp_desscription_length = about["__description__"]
126127
ogp_site_name = about["__title__"]
127128

128-
htmlhelp_basename = "%sdoc" % about["__title__"]
129+
htmlhelp_basename = f"{about['__title__']}doc"
129130

130131
latex_documents = [
131132
(
132133
"index",
133-
"{}.tex".format(about["__package_name__"]),
134-
"{} Documentation".format(about["__title__"]),
134+
f"{about['__package_name__']}.tex",
135+
f"{about['__title__']} Documentation",
135136
about["__author__"],
136137
"manual",
137138
)
@@ -141,7 +142,7 @@
141142
(
142143
"index",
143144
about["__package_name__"],
144-
"{} Documentation".format(about["__title__"]),
145+
f"{about['__title__']} Documentation",
145146
about["__author__"],
146147
1,
147148
)
@@ -150,8 +151,8 @@
150151
texinfo_documents = [
151152
(
152153
"index",
153-
"{}".format(about["__package_name__"]),
154-
"{} Documentation".format(about["__title__"]),
154+
about["__package_name__"],
155+
f"{about['__title__']} Documentation",
155156
about["__author__"],
156157
about["__package_name__"],
157158
about["__description__"],
@@ -220,7 +221,7 @@ def linkcode_resolve(
220221
else:
221222
linespec = ""
222223

223-
fn = relpath(fn, start=dirname(libtmux.__file__))
224+
fn = relpath(fn, start=pathlib.Path(libtmux.__file__).parent)
224225

225226
if "dev" in about["__version__"]:
226227
return "{}/blob/master/{}/{}/{}{}".format(
@@ -244,11 +245,9 @@ def linkcode_resolve(
244245
def remove_tabs_js(app: "Sphinx", exc: Exception) -> None:
245246
# Fix for sphinx-inline-tabs#18
246247
if app.builder.format == "html" and not exc:
247-
tabs_js = Path(app.builder.outdir) / "_static" / "tabs.js"
248-
try:
249-
tabs_js.unlink() # use missing_ok=True when python 3.7 deprecated
250-
except FileNotFoundError:
251-
pass
248+
tabs_js = pathlib.Path(app.builder.outdir) / "_static" / "tabs.js"
249+
with contextlib.suppress(FileNotFoundError):
250+
tabs_js.unlink() # When python 3.7 deprecated, use missing_ok=True
252251

253252

254253
def setup(app: "Sphinx") -> None:

src/libtmux/common.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
import subprocess
1212
import sys
1313
import typing as t
14-
from typing import Dict, Generic, KeysView, List, Optional, TypeVar, Union, overload
14+
from typing import Dict, Optional, Union
1515

1616
from . import exc
1717
from ._compat import LooseVersion, console_to_str, str_from_console
1818

1919
if t.TYPE_CHECKING:
20-
from typing_extensions import Literal
21-
22-
from libtmux.pane import Pane
23-
from libtmux.session import Session
24-
from libtmux.window import Window
20+
pass
2521

2622

2723
logger = logging.getLogger(__name__)
@@ -73,7 +69,7 @@ def set_environment(self, name: str, value: str) -> None:
7369
cmd = self.cmd(*args)
7470

7571
if cmd.stderr:
76-
stderr = (
72+
(
7773
cmd.stderr[0]
7874
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
7975
else cmd.stderr
@@ -97,7 +93,7 @@ def unset_environment(self, name: str) -> None:
9793
cmd = self.cmd(*args)
9894

9995
if cmd.stderr:
100-
stderr = (
96+
(
10197
cmd.stderr[0]
10298
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
10399
else cmd.stderr
@@ -120,7 +116,7 @@ def remove_environment(self, name: str) -> None:
120116
cmd = self.cmd(*args)
121117

122118
if cmd.stderr:
123-
stderr = (
119+
(
124120
cmd.stderr[0]
125121
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
126122
else cmd.stderr
@@ -149,13 +145,13 @@ def show_environment(self) -> Dict[str, Union[bool, str]]:
149145
output = cmd.stdout
150146
vars = [tuple(item.split("=", 1)) for item in output]
151147
vars_dict: t.Dict[str, t.Union[str, bool]] = {}
152-
for t in vars:
153-
if len(t) == 2:
154-
vars_dict[t[0]] = t[1]
155-
elif len(t) == 1:
156-
vars_dict[t[0]] = True
148+
for _t in vars:
149+
if len(_t) == 2:
150+
vars_dict[_t[0]] = _t[1]
151+
elif len(_t) == 1:
152+
vars_dict[_t[0]] = True
157153
else:
158-
raise ValueError("unexpected variable %s", t)
154+
raise ValueError(f"unexpected variable {_t}")
159155

160156
return vars_dict
161157

@@ -186,13 +182,13 @@ def getenv(self, name: str) -> Optional[t.Union[str, bool]]:
186182
output = cmd.stdout
187183
vars = [tuple(item.split("=", 1)) for item in output]
188184
vars_dict: t.Dict[str, t.Union[str, bool]] = {}
189-
for t in vars:
190-
if len(t) == 2:
191-
vars_dict[t[0]] = t[1]
192-
elif len(t) == 1:
193-
vars_dict[t[0]] = True
185+
for _t in vars:
186+
if len(_t) == 2:
187+
vars_dict[_t[0]] = _t[1]
188+
elif len(_t) == 1:
189+
vars_dict[_t[0]] = True
194190
else:
195-
raise ValueError("unexpected variable %s", t)
191+
raise ValueError(f"unexpected variable {_t}")
196192

197193
return vars_dict.get(name)
198194

src/libtmux/pane.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
from libtmux.common import tmux_cmd
1515
from libtmux.neo import Obj, fetch_obj
1616

17-
from . import exc, formats
18-
from .common import PaneDict
17+
from . import exc
1918

2019
if t.TYPE_CHECKING:
2120
from typing_extensions import Literal

0 commit comments

Comments
 (0)