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
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
docs(Server): Tighten and correct docstrings
  • Loading branch information
tony committed Feb 6, 2024
commit 98496f0c77a03b2bef9831b93dcd43e03806a453
41 changes: 16 additions & 25 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Pythonization of the :term:`tmux(1)` server.
"""Wrapper for :term:`tmux(1)` server.

libtmux.server
~~~~~~~~~~~~~~
Expand Down Expand Up @@ -38,8 +38,7 @@


class Server(EnvironmentMixin):
"""
The :term:`tmux(1)` :term:`Server` [server_manual]_.
""":term:`tmux(1)` :term:`Server` [server_manual]_.

- :attr:`Server.sessions` [:class:`Session`, ...]

Expand Down Expand Up @@ -136,7 +135,7 @@ def __init__(
self.colors = colors

def is_alive(self) -> bool:
"""If server alive or not.
"""Return True if tmux server alive.

>>> tmux = Server(socket_name="no_exist")
>>> assert not tmux.is_alive()
Expand Down Expand Up @@ -175,8 +174,7 @@ def raise_if_dead(self) -> None:
# Command
#
def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
"""
Execute tmux command and return output.
"""Execute tmux command, rsepective of socket name and file, return output.

Examples
--------
Expand Down Expand Up @@ -212,8 +210,7 @@ def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:

@property
def attached_sessions(self) -> t.List[Session]:
"""
Return active :class:`Session` objects.
"""Return active :class:`Session`s.

Examples
--------
Expand Down Expand Up @@ -242,8 +239,7 @@ def attached_sessions(self) -> t.List[Session]:
return attached_sessions

def has_session(self, target_session: str, exact: bool = True) -> bool:
"""
Return True if session exists. ``$ tmux has-session``.
"""Return True if session exists.

Parameters
----------
Expand Down Expand Up @@ -275,12 +271,11 @@ def has_session(self, target_session: str, exact: bool = True) -> bool:
return False

def kill_server(self) -> None:
"""``$ tmux kill-server``."""
"""Kill tmux server."""
self.cmd("kill-server")

def kill_session(self, target_session: t.Union[str, int]) -> "Server":
"""
Kill the tmux session with ``$ tmux kill-session``, return ``self``.
"""Kill tmux session.

Parameters
----------
Expand All @@ -304,8 +299,7 @@ def kill_session(self, target_session: t.Union[str, int]) -> "Server":
return self

def switch_client(self, target_session: str) -> None:
"""
``$ tmux switch-client``.
"""Switch tmux client.

Parameters
----------
Expand All @@ -324,7 +318,7 @@ def switch_client(self, target_session: str) -> None:
raise exc.LibTmuxException(proc.stderr)

def attach_session(self, target_session: t.Optional[str] = None) -> None:
"""``$ tmux attach-session`` aka alias: ``$ tmux attach``.
"""Attach tmux session.

Parameters
----------
Expand Down Expand Up @@ -359,8 +353,7 @@ def new_session(
*args: t.Any,
**kwargs: t.Any,
) -> Session:
"""
Return :class:`Session` from ``$ tmux new-session``.
"""Create new session, returns new :class:`Session`.

Uses ``-P`` flag to print session info, ``-F`` for return formatting
returns new Session object.
Expand Down Expand Up @@ -498,7 +491,7 @@ def new_session(
#
@property
def sessions(self) -> QueryList[Session]: # type:ignore
"""Sessions belonging server.
"""Sessions contained in server.

Can be accessed via
:meth:`.sessions.get() <libtmux._internal.query_list.QueryList.get()>` and
Expand All @@ -519,7 +512,7 @@ def sessions(self) -> QueryList[Session]: # type:ignore

@property
def windows(self) -> QueryList[Window]: # type:ignore
"""Windows belonging server.
"""Windows contained in server's sessions.

Can be accessed via
:meth:`.windows.get() <libtmux._internal.query_list.QueryList.get()>` and
Expand All @@ -538,7 +531,7 @@ def windows(self) -> QueryList[Window]: # type:ignore

@property
def panes(self) -> QueryList[Pane]: # type:ignore
"""Panes belonging server.
"""Panes contained in tmux server (across all windows in all sessions).

Can be accessed via
:meth:`.panes.get() <libtmux._internal.query_list.QueryList.get()>` and
Expand Down Expand Up @@ -582,8 +575,7 @@ def __repr__(self) -> str:
# Legacy: Redundant stuff we want to remove
#
def _list_panes(self) -> t.List[PaneDict]:
"""
Return list of panes in :py:obj:`dict` form.
"""Return list of panes in :py:obj:`dict` form.

Retrieved from ``$ tmux(1) list-panes`` stdout.

Expand All @@ -599,8 +591,7 @@ def _list_panes(self) -> t.List[PaneDict]:
return [p.__dict__ for p in self.panes]

def _update_panes(self) -> "Server":
"""
Update internal pane data and return ``self`` for chainability.
"""Update internal pane data and return ``self`` for chainability.

.. deprecated:: 0.16

Expand Down
0