diff --git a/conftest.py b/conftest.py index 299041497..c00eaa576 100644 --- a/conftest.py +++ b/conftest.py @@ -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 diff --git a/docs/conf.py b/docs/conf.py index dcb51b2ca..e6399b96d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 ----- diff --git a/src/libtmux/_internal/query_list.py b/src/libtmux/_internal/query_list.py index 07f10ef6a..b9dbbbafb 100644 --- a/src/libtmux/_internal/query_list.py +++ b/src/libtmux/_internal/query_list.py @@ -29,7 +29,7 @@ def __call__( class MultipleObjectsReturned(Exception): - """The requested object does not exist""" + """The requested object does not exist.""" class ObjectDoesNotExist(Exception): @@ -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' diff --git a/src/libtmux/_vendor/version.py b/src/libtmux/_vendor/version.py index 252b683f5..ba50a37a8 100644 --- a/src/libtmux/_vendor/version.py +++ b/src/libtmux/_vendor/version.py @@ -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) diff --git a/src/libtmux/exc.py b/src/libtmux/exc.py index 962cbe600..bf35a73f4 100644 --- a/src/libtmux/exc.py +++ b/src/libtmux/exc.py @@ -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: @@ -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") diff --git a/src/libtmux/pane.py b/src/libtmux/pane.py index 70d94b972..c1898dad6 100644 --- a/src/libtmux/pane.py +++ b/src/libtmux/pane.py @@ -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' @@ -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' @@ -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 @@ -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 @@ -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) diff --git a/src/libtmux/pytest_plugin.py b/src/libtmux/pytest_plugin.py index 0cfb1c594..b5ec77794 100644 --- a/src/libtmux/pytest_plugin.py +++ b/src/libtmux/pytest_plugin.py @@ -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 @@ -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 @@ -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 diff --git a/src/libtmux/server.py b/src/libtmux/server.py index 48d8ced01..2bae62e20 100644 --- a/src/libtmux/server.py +++ b/src/libtmux/server.py @@ -607,16 +607,12 @@ 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) @@ -624,9 +620,7 @@ def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Session]: 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) @@ -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] @@ -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 """ diff --git a/src/libtmux/session.py b/src/libtmux/session.py index f8f774552..fe5311e47 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -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" ] @@ -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. @@ -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' @@ -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_...' @@ -591,32 +589,24 @@ 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) @@ -624,16 +614,12 @@ def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Window]: 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] @@ -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 """ diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 0d8f692c2..0278dc8b4 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -564,7 +564,7 @@ def __repr__(self) -> str: # @property def id(self) -> t.Optional[str]: - """Alias of :attr:`Window.window_id` + """Alias of :attr:`Window.window_id`. >>> window.id '@1' @@ -576,7 +576,7 @@ def id(self) -> t.Optional[str]: @property def name(self) -> t.Optional[str]: - """Alias of :attr:`Window.window_name` + """Alias of :attr:`Window.window_name`. >>> window.name '...' @@ -588,7 +588,7 @@ def name(self) -> t.Optional[str]: @property def index(self) -> t.Optional[str]: - """Alias of :attr:`Window.window_index` + """Alias of :attr:`Window.window_index`. >>> window.index '1' @@ -600,7 +600,7 @@ def index(self) -> t.Optional[str]: @property def height(self) -> t.Optional[str]: - """Alias of :attr:`Window.window_height` + """Alias of :attr:`Window.window_height`. >>> window.height.isdigit() True @@ -612,7 +612,7 @@ def height(self) -> t.Optional[str]: @property def width(self) -> t.Optional[str]: - """Alias of :attr:`Window.window_width` + """Alias of :attr:`Window.window_width`. >>> window.width.isdigit() True @@ -626,34 +626,22 @@ def width(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("Window.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. window['{key}'] is deprecated", stacklevel=2) return getattr(self, key) def get_by_id(self, id: str) -> t.Optional[Pane]: - """ - .. deprecated:: 0.16 - - """ + """.. deprecated:: 0.16.""" warnings.warn("Window.get_by_id() is deprecated", stacklevel=2) return self.panes.get(pane_id=id, default=None) def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Pane]: - """ - .. deprecated:: 0.16 - - """ + """.. deprecated:: 0.16.""" warnings.warn("Window.where() is deprecated", stacklevel=2) try: return self.panes.filter(**kwargs) @@ -661,18 +649,12 @@ def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Pane]: return [] def find_where(self, kwargs: t.Dict[str, t.Any]) -> t.Optional[Pane]: - """ - .. deprecated:: 0.16 - - """ + """.. deprecated:: 0.16.""" warnings.warn("Window.find_where() is deprecated", stacklevel=2) return self.panes.get(default=None, **kwargs) def _list_panes(self) -> t.List[PaneDict]: - """ - .. deprecated:: 0.16 - - """ + """.. deprecated:: 0.16.""" warnings.warn("Window._list_panes() is deprecated", stacklevel=2) return [pane.__dict__ for pane in self.panes] @@ -695,7 +677,7 @@ def list_panes(self) -> t.List["Pane"]: @property def children(self) -> QueryList["Pane"]: # 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 """ diff --git a/tests/legacy_api/test_server.py b/tests/legacy_api/test_server.py index a972be229..c06909e0e 100644 --- a/tests/legacy_api/test_server.py +++ b/tests/legacy_api/test_server.py @@ -86,14 +86,14 @@ def test_show_environment_not_set(server: Server) -> None: def test_new_session(server: Server) -> None: - """Server.new_session creates and returns valid session""" + """Server.new_session creates and returns valid session.""" mysession = server.new_session("test_new_session") assert mysession.get("session_name") == "test_new_session" assert server.has_session("test_new_session") def test_new_session_no_name(server: Server) -> None: - """Server.new_session works with no name""" + """Server.new_session works with no name.""" first_session = server.new_session() first_session_name = first_session.get("session_name") assert first_session_name is not None @@ -111,7 +111,7 @@ def test_new_session_no_name(server: Server) -> None: def test_new_session_shell(server: Server) -> None: """Server.new_session creates and returns valid session running with - specified command + specified command. """ cmd = "sleep 1m" mysession = server.new_session("test_new_session", window_command=cmd) diff --git a/tests/legacy_api/test_window.py b/tests/legacy_api/test_window.py index 1255e5f28..3b208d0be 100644 --- a/tests/legacy_api/test_window.py +++ b/tests/legacy_api/test_window.py @@ -278,7 +278,7 @@ def test_set_window_option_invalid(session: Session) -> None: def test_move_window(session: Session) -> None: - """Window.move_window results in changed index""" + """Window.move_window results in changed index.""" window = session.new_window(window_name="test_window") assert window.index is not None new_index = str(int(window.index) + 1) diff --git a/tests/test_server.py b/tests/test_server.py index c60c103a3..5f7aa8fb5 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -86,14 +86,14 @@ def test_show_environment_not_set(server: Server) -> None: def test_new_session(server: Server) -> None: - """Server.new_session creates and returns valid session""" + """Server.new_session creates and returns valid session.""" mysession = server.new_session("test_new_session") assert mysession.session_name == "test_new_session" assert server.has_session("test_new_session") def test_new_session_no_name(server: Server) -> None: - """Server.new_session works with no name""" + """Server.new_session works with no name.""" first_session = server.new_session() first_session_name = first_session.session_name assert first_session_name is not None @@ -111,7 +111,7 @@ def test_new_session_no_name(server: Server) -> None: def test_new_session_shell(server: Server) -> None: """Server.new_session creates and returns valid session running with - specified command + specified command. """ cmd = "sleep 1m" mysession = server.new_session("test_new_session", window_command=cmd) @@ -132,7 +132,7 @@ def test_new_session_shell(server: Server) -> None: @pytest.mark.skipif(has_version("3.2"), reason="Wrong width returned with 3.2") def test_new_session_width_height(server: Server) -> None: """Server.new_session creates and returns valid session running with - specified width /height + specified width /height. """ cmd = "/usr/bin/env PS1='$ ' sh" mysession = server.new_session( diff --git a/tests/test_window.py b/tests/test_window.py index c61261cb1..ca1a15545 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -290,7 +290,7 @@ def test_set_window_option_invalid(session: Session) -> None: def test_move_window(session: Session) -> None: - """Window.move_window results in changed index""" + """Window.move_window results in changed index.""" window = session.new_window(window_name="test_window") assert window.window_index is not None new_index = str(int(window.window_index) + 1)