8000 Docstring updates, bolster linting by tony · Pull Request #514 · tmux-python/libtmux · GitHub
[go: up one dir, main page]

Skip to content

Docstring updates, bolster linting #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix!: Fix shadowing of python builtins
docs/conf.py:57:1: A001 Variable `copyright` is shadowing a Python builtin
src/libtmux/common.py:142:9: A001 Variable `vars` is shadowing a Python builtin
src/libtmux/common.py:179:9: A001 Variable `vars` is shadowing a Python builtin
src/libtmux/server.py:618:25: A002 Argument `id` is shadowing a Python builtin
src/libtmux/session.py:621:25: A002 Argument `id` is shadowing a Python builtin
src/libtmux/window.py:656:25: A002 Argument `id` is shadowing a Python builtin
  • Loading branch information
tony committed Feb 6, 2024
commit 00a5863f1dfe43f78a84a6794911e3638bb0337f
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
master_doc = "index"

project = about["__title__"]
copyright = about["__copyright__"]
project_copyright = about["__copyright__"]

version = "%s" % (".".join(about["__version__"].split("."))[:2])
release = "%s" % (about["__version__"])
Expand Down
24 changes: 12 additions & 12 deletions src/libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ def show_environment(self) -> Dict[str, Union[bool, str]]:
tmux_args += [self._add_option]
cmd = self.cmd(*tmux_args)
output = cmd.stdout
vars = [tuple(item.split("=", 1)) for item in output]
vars_dict: t.Dict[str, t.Union[str, bool]] = {}
for _t in vars:
opts = [tuple(item.split("=", 1)) for item in output]
opts_dict: t.Dict[str, t.Union[str, bool]] = {}
for _t in opts:
if len(_t) == 2:
vars_dict[_t[0]] = _t[1]
opts_dict[_t[0]] = _t[1]
elif len(_t) == 1:
vars_dict[_t[0]] = True
opts_dict[_t[0]] = True
else:
raise exc.VariableUnpackingError(variable=_t)

return vars_dict
return opts_dict

def getenv(self, name: str) -> Optional[t.Union[str, bool]]:
"""Show environment variable ``$ tmux show-environment -t [session] <name>``.
Expand All @@ -174,17 +174,17 @@ def getenv(self, name: str) -> Optional[t.Union[str, bool]]:
tmux_args += (name,)
cmd = self.cmd(*tmux_args)
output = cmd.stdout
vars = [tuple(item.split("=", 1)) for item in output]
vars_dict: t.Dict[str, t.Union[str, bool]] = {}
for _t in vars:
opts = [tuple(item.split("=", 1)) for item in output]
opts_dict: t.Dict[str, t.Union[str, bool]] = {}
for _t in opts:
if len(_t) == 2:
vars_dict[_t[0]] = _t[1]
opts_dict[_t[0]] = _t[1]
elif len(_t) == 1:
vars_dict[_t[0]] = True
opts_dict[_t[0]] = True
else:
raise exc.VariableUnpackingError(variable=_t)

return vars_dict.get(name)
return opts_dict.get(name)


class tmux_cmd:
Expand Down
4 changes: 2 additions & 2 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def _update_panes(self) -> "Server":
self._list_panes()
return self

def get_by_id(self, id: str) -> t.Optional[Session]:
def get_by_id(self, session_id: str) -> t.Optional[Session]:
"""Return session by id. Deprecated in favor of :meth:`.sessions.get()`.

.. deprecated:: 0.16
Expand All @@ -615,7 +615,7 @@ def get_by_id(self, id: str) -> t.Optional[Session]:

"""
warnings.warn("Server.get_by_id() is deprecated", stacklevel=2)
return self.sessions.get(session_id=id, default=None)
return self.sessions.get(session_id=session_id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Session]:
"""Filter through sessions, return list of :class:`Session`.
Expand Down
4 changes: 2 additions & 2 deletions src/libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def __getitem__(self, key: str) -> t.Any:
)
return getattr(self, key)

def get_by_id(self, id: str) -> t.Optional[Window]:
def get_by_id(self, session_id: str) -> t.Optional[Window]:
"""Return window by id. Deprecated in favor of :meth:`.windows.get()`.

.. deprecated:: 0.16
Expand All @@ -627,7 +627,7 @@ def get_by_id(self, id: str) -> t.Optional[Window]:

"""
warnings.warn("Session.get_by_id() is deprecated", stacklevel=2)
return self.windows.get(window_id=id, default=None)
return self.windows.get(window_id=session_id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Window]:
"""Filter through windows, return list of :class:`Window`.
Expand Down
4 changes: 2 additions & 2 deletions src/libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def __getitem__(self, key: str) -> t.Any:
warnings.warn(f"Item lookups, e.g. window['{key}'] is deprecated", stacklevel=2)
return getattr(self, key)

def get_by_id(self, id: str) -> t.Optional[Pane]:
def get_by_id(self, pane_id: str) -> t.Optional[Pane]:
"""Return pane by id. Deprecated in favor of :meth:`.panes.get()`.

.. deprecated:: 0.16
Expand All @@ -662,7 +662,7 @@ def get_by_id(self, id: str) -> t.Optional[Pane]:

"""
warnings.warn("Window.get_by_id() is deprecated", stacklevel=2)
return self.panes.get(pane_id=id, default=None)
return self.panes.get(pane_id=pane_id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Pane]:
"""Filter through panes, return list of :class:`Pane`.
Expand Down
0