Skip to content

Commit

Permalink
Revert "Revert "ruff(pydocstyle): Run automated fixes (unsafe ones)""
Browse files Browse the repository at this point in the history
This reverts commit eb7e9c1.
  • Loading branch information
tony committed Nov 25, 2023
1 parent eb7e9c1 commit 376ab14
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 105 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Conftest.py (root-level)
"""Conftest.py (root-level).
We keep this in root pytest fixtures in pytest's doctest plugin to be available, as well
as avoiding conftest.py from being included in the wheel, in addition to pytest_plugin
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@

def linkcode_resolve(domain: str, info: t.Dict[str, str]) -> t.Union[None, str]:
"""
Determine the URL corresponding to Python object
Determine the URL corresponding to Python object.
Notes
-----
Expand Down
4 changes: 2 additions & 2 deletions src/libtmux/_internal/query_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __call__(


class MultipleObjectsReturned(Exception):
"""The requested object does not exist"""
"""The requested object does not exist."""


class ObjectDoesNotExist(Exception):
Expand All @@ -40,7 +40,7 @@ def keygetter(
obj: "Mapping[str, t.Any]",
path: str,
) -> t.Union[None, t.Any, str, t.List[str], "Mapping[str, str]"]:
"""obj, "foods__breakfast", obj['foods']['breakfast']
"""obj, "foods__breakfast", obj['foods']['breakfast'].
>>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods__breakfast")
'cereal'
Expand Down
4 changes: 1 addition & 3 deletions src/libtmux/_vendor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ def _parse_letter_version(


def _parse_local_version(local: str) -> Optional[LocalType]:
"""
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
"""
"""Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve")."""
if local is not None:
return tuple(
part.lower() if not part.isdigit() else int(part)
Expand Down
16 changes: 8 additions & 8 deletions src/libtmux/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ class AmbiguousOption(OptionError):


class WaitTimeout(LibTmuxException):
"""Function timed out without meeting condition"""
"""Function timed out without meeting condition."""


class VariableUnpackingError(LibTmuxException):
"""Error unpacking variable"""
"""Error unpacking variable."""

def __init__(self, variable: t.Optional[t.Any] = None, *args: object):
return super().__init__(f"Unexpected variable: {variable!s}")


class PaneError(LibTmuxException):
"""Any type of pane related error"""
"""Any type of pane related error."""


class PaneNotFound(PaneError):
"""Pane not found"""
"""Pane not found."""

def __init__(self, pane_id: t.Optional[str] = None, *args: object):
if pane_id is not None:
Expand All @@ -107,25 +107,25 @@ def __init__(self, pane_id: t.Optional[str] = None, *args: object):


class WindowError(LibTmuxException):
"""Any type of window related error"""
"""Any type of window related error."""


class MultipleActiveWindows(WindowError):
"""Multiple active windows"""
"""Multiple active windows."""

def __init__(self, count: int, *args: object):
return super().__init__(f"Multiple active windows: {count} found")


class NoActiveWindow(WindowError):
"""No active window found"""
"""No active window found."""

def __init__(self, *args: object):
return super().__init__("No active windows found")


class NoWindowsExist(WindowError):
"""No windows exist for object"""
"""No windows exist for object."""

def __init__(self, *args: object):
return super().__init__("No windows exist for object")
16 changes: 6 additions & 10 deletions src/libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __repr__(self) -> str:
#
@property
def id(self) -> t.Optional[str]:
"""Alias of :attr:`Pane.pane_id`
"""Alias of :attr:`Pane.pane_id`.
>>> pane.id
'%1'
Expand All @@ -398,7 +398,7 @@ def id(self) -> t.Optional[str]:

@property
def index(self) -> t.Optional[str]:
"""Alias of :attr:`Pane.pane_index`
"""Alias of :attr:`Pane.pane_index`.
>>> pane.index
'0'
Expand All @@ -410,7 +410,7 @@ def index(self) -> t.Optional[str]:

@property
def height(self) -> t.Optional[str]:
"""Alias of :attr:`Pane.pane_height`
"""Alias of :attr:`Pane.pane_height`.
>>> pane.height.isdigit()
True
Expand All @@ -422,7 +422,7 @@ def height(self) -> t.Optional[str]:

@property
def width(self) -> t.Optional[str]:
"""Alias of :attr:`Pane.pane_width`
"""Alias of :attr:`Pane.pane_width`.
>>> pane.width.isdigit()
True
Expand All @@ -436,15 +436,11 @@ def width(self) -> t.Optional[str]:
# Legacy
#
def get(self, key: str, default: t.Optional[t.Any] = None) -> t.Any:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Pane.get() is deprecated", stacklevel=2)
return getattr(self, key, default)

def __getitem__(self, key: str) -> t.Any:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn(f"Item lookups, e.g. pane['{key}'] is deprecated", stacklevel=2)
return getattr(self, key)
6 changes: 3 additions & 3 deletions src/libtmux/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def server(
monkeypatch: pytest.MonkeyPatch,
config_file: pathlib.Path,
) -> Server:
"""Returns a new, temporary :class:`libtmux.Server`
"""Returns a new, temporary :class:`libtmux.Server`.
>>> from libtmux.server import Server
Expand Down Expand Up @@ -146,7 +146,7 @@ def fin() -> None:

@pytest.fixture(scope="function")
def session_params() -> t.Dict[str, t.Any]:
"""Returns a new, temporary :class:`libtmux.Session`
"""Returns a new, temporary :class:`libtmux.Session`.
>>> import pytest
>>> from libtmux.session import Session
Expand Down Expand Up @@ -186,7 +186,7 @@ def session_params() -> t.Dict[str, t.Any]:
def session(
request: pytest.FixtureRequest, session_params: t.Dict[str, t.Any], server: Server
) -> "Session":
"""Returns a new, temporary :class:`libtmux.Session`
"""Returns a new, temporary :class:`libtmux.Session`.
>>> from libtmux.session import Session
Expand Down
18 changes: 5 additions & 13 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,26 +607,20 @@ def _update_panes(self) -> "Server":
return self

def get_by_id(self, id: str) -> t.Optional[Session]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Server.get_by_id() is deprecated", stacklevel=2)
return self.sessions.get(session_id=id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Session]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Server.find_where() is deprecated", stacklevel=2)
try:
return self.sessions.filter(**kwargs)
except IndexError:
return []

def find_where(self, kwargs: t.Dict[str, t.Any]) -> t.Optional[Session]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Server.find_where() is deprecated", stacklevel=2)
return self.sessions.get(default=None, **kwargs)

Expand Down Expand Up @@ -662,9 +656,7 @@ def _sessions(self) -> t.List[SessionDict]:
return self._list_sessions()

def _list_sessions(self) -> t.List["SessionDict"]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Server._list_sessions() is deprecated", stacklevel=2)
return [s.__dict__ for s in self.sessions]

Expand All @@ -682,7 +674,7 @@ def list_sessions(self) -> t.List[Session]:

@property
def children(self) -> QueryList["Session"]: # type:ignore
"""Was used by TmuxRelationalObject (but that's longer used in this class)
"""Was used by TmuxRelationalObject (but that's longer used in this class).
.. deprecated:: 0.16
"""
Expand Down
36 changes: 11 additions & 25 deletions src/libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ def select_window(self, target_window: t.Union[str, int]) -> "Window":
#
@property
def attached_window(self) -> "Window":
"""
Return active :class:`Window` object.
"""
"""Return active :class:`Window` object."""
active_windows = [
window for window in self.windows if window.window_active == "1"
]
Expand Down Expand Up @@ -521,7 +519,7 @@ def new_window(
)

def kill_window(self, target_window: t.Optional[str] = None) -> None:
"""Close a tmux window, and all panes inside it, ``$ tmux kill-window``
"""Close a tmux window, and all panes inside it, ``$ tmux kill-window``.
Kill the current window or the window at ``target-window``. removing it
from any sessions to which it is linked.
Expand Down Expand Up @@ -565,7 +563,7 @@ def __repr__(self) -> str:
#
@property
def id(self) -> t.Optional[str]:
"""Alias of :attr:`Session.session_id`
"""Alias of :attr:`Session.session_id`.
>>> session.id
'$1'
Expand All @@ -577,7 +575,7 @@ def id(self) -> t.Optional[str]:

@property
def name(self) -> t.Optional[str]:
"""Alias of :attr:`Session.session_name`
"""Alias of :attr:`Session.session_name`.
>>> session.name
'libtmux_...'
Expand All @@ -591,49 +589,37 @@ def name(self) -> t.Optional[str]:
# Legacy: Redundant stuff we want to remove
#
def get(self, key: str, default: t.Optional[t.Any] = None) -> t.Any:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Session.get() is deprecated", stacklevel=2)
return getattr(self, key, default)

def __getitem__(self, key: str) -> t.Any:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn(
f"Item lookups, e.g. session['{key}'] is deprecated", stacklevel=2
)
return getattr(self, key)

def get_by_id(self, id: str) -> t.Optional[Window]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Session.get_by_id() is deprecated", stacklevel=2)
return self.windows.get(window_id=id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Window]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Session.where() is deprecated", stacklevel=2)
try:
return self.windows.filter(**kwargs)
except IndexError:
return []

def find_where(self, kwargs: t.Dict[str, t.Any]) -> t.Optional[Window]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Session.find_where() is deprecated", stacklevel=2)
return self.windows.get(default=None, **kwargs)

def _list_windows(self) -> t.List["WindowDict"]:
"""
.. deprecated:: 0.16
"""
""".. deprecated:: 0.16."""
warnings.warn("Session._list_windows() is deprecated", stacklevel=2)
return [w.__dict__ for w in self.windows]

Expand All @@ -656,7 +642,7 @@ def list_windows(self) -> t.List["Window"]:

@property
def children(self) -> QueryList["Window"]: # type:ignore
"""Was used by TmuxRelationalObject (but that's longer used in this class)
"""Was used by TmuxRelationalObject (but that's longer used in this class).
.. deprecated:: 0.16
"""
Expand Down
Loading

0 comments on commit 376ab14

Please sign in to comment.