Skip to content

Commit

Permalink
ruff(pydocstyle): Run automated fixes (unsafe ones)
Browse files Browse the repository at this point in the history
`ruff --show-fixes --fix-only --unsafe-fixes .`

Fixed 35 errors:
- conftest.py:
    1 × D400 (ends-in-period)
- docs/_ext/aafig.py:
    2 × D200 (fits-on-one-line)
    1 × D400 (ends-in-period)
- docs/conf.py:
    1 × D400 (ends-in-period)
- src/tmuxp/_types.py:
    1 × D400 (ends-in-period)
- src/tmuxp/cli/debug_info.py:
    4 × D200 (fits-on-one-line)
- src/tmuxp/cli/load.py:
    6 × D400 (ends-in-period)
    1 × D200 (fits-on-one-line)
- src/tmuxp/cli/utils.py:
    5 × D400 (ends-in-period)
    1 × D200 (fits-on-one-line)
- src/tmuxp/config_reader.py:
    1 × D400 (ends-in-period)
- src/tmuxp/plugin.py:
    2 × D200 (fits-on-one-line)
- src/tmuxp/shell.py:
    1 × D400 (ends-in-period)
- src/tmuxp/types.py:
    1 × D400 (ends-in-period)
- src/tmuxp/util.py:
    1 × D400 (ends-in-period)
- tests/fixtures/pluginsystem/partials/_types.py:
    2 × D400 (ends-in-period)
- tests/fixtures/utils.py:
    2 × D400 (ends-in-period)
- tests/tests/test_helpers.py:
    1 × D400 (ends-in-period)
- tests/workspace/conftest.py:
    1 × D400 (ends-in-period)

Fixed 35 errors.
  • Loading branch information
tony committed Dec 9, 2023
1 parent a752a07 commit 5aa4487
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 53 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.
Expand Down
10 changes: 3 additions & 7 deletions docs/_ext/aafig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
sphinxcontrib.aafig
sphinxcontrib.aafig.
~~~~~~~~~~~~~~~~~~~
Allow embedded ASCII art to be rendered as nice looking images
Expand Down Expand Up @@ -61,9 +61,7 @@ class AafigError(SphinxError):


class AafigDirective(images.Image): # type:ignore
"""
Directive to insert an ASCII art figure to be rendered by aafigure.
"""
"""Directive to insert an ASCII art figure to be rendered by aafigure."""

has_content = True
required_arguments = 0
Expand Down Expand Up @@ -155,9 +153,7 @@ def __init__(self, *args: object, **kwargs: object) -> None:
def render_aafigure(
app: "Sphinx", text: str, options: t.Dict[str, str]
) -> t.Tuple[str, str, t.Optional[str], t.Optional[str]]:
"""
Render an ASCII art figure into the requested format output file.
"""
"""Render an ASCII art figure into the requested format output file."""
if aafigure is None:
raise AafigureNotInstalled()

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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
2 changes: 1 addition & 1 deletion src/tmuxp/_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Internal, :const:`typing.TYPE_CHECKING` guarded :term:`type annotations <annotation>`
"""Internal, :const:`typing.TYPE_CHECKING` guarded :term:`type annotations <annotation>`.
These are _not_ to be imported at runtime as `typing_extensions` is not
bundled with tmuxp. Usage example:
Expand Down
16 changes: 4 additions & 12 deletions src/tmuxp/cli/debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,18 @@ def create_debug_info_subparser(
def command_debug_info(
parser: t.Optional[argparse.ArgumentParser] = None,
) -> None:
"""
Print debug info to submit with Issues.
"""
"""Print debug info to submit with Issues."""

def prepend_tab(strings: t.List[str]) -> t.List[str]:
"""
Prepend tab to strings in list.
"""
"""Prepend tab to strings in list."""
return ["\t%s" % x for x in strings]

def output_break() -> str:
"""
Generate output break.
"""
"""Generate output break."""
return "-" * 25

def format_tmux_resp(std_resp: tmux_cmd) -> str:
"""
Format tmux command response for tmuxp stdout.
"""
"""Format tmux command response for tmuxp stdout."""
return "\n".join(
[
"\n".join(prepend_tab(std_resp.stdout)),
Expand Down
14 changes: 6 additions & 8 deletions src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ def set_layout_hook(session: Session, hook_name: str) -> None:


def load_plugins(session_config: t.Dict[str, t.Any]) -> t.List[t.Any]:
"""
Load and return plugins in workspace
"""
"""Load and return plugins in workspace."""
plugins = []
if "plugins" in session_config:
for plugin in session_config["plugins"]:
Expand Down Expand Up @@ -155,7 +153,7 @@ def load_plugins(session_config: t.Dict[str, t.Any]) -> t.List[t.Any]:

def _reattach(builder: WorkspaceBuilder) -> None:
"""
Reattach session (depending on env being inside tmux already or not)
Reattach session (depending on env being inside tmux already or not).
Parameters
----------
Expand Down Expand Up @@ -185,7 +183,7 @@ def _reattach(builder: WorkspaceBuilder) -> None:

def _load_attached(builder: WorkspaceBuilder, detached: bool) -> None:
"""
Load workspace in new session
Load workspace in new session.
Parameters
----------
Expand Down Expand Up @@ -219,7 +217,7 @@ def _load_attached(builder: WorkspaceBuilder, detached: bool) -> None:

def _load_detached(builder: WorkspaceBuilder) -> None:
"""
Load workspace in new session but don't attach
Load workspace in new session but don't attach.
Parameters
----------
Expand All @@ -238,7 +236,7 @@ def _load_detached(builder: WorkspaceBuilder) -> None:

def _load_append_windows_to_current_session(builder: WorkspaceBuilder) -> None:
"""
Load workspace as new windows in current session
Load workspace as new windows in current session.
Parameters
----------
Expand All @@ -254,7 +252,7 @@ def _load_append_windows_to_current_session(builder: WorkspaceBuilder) -> None:

def _setup_plugins(builder: WorkspaceBuilder) -> Session:
"""
Runs after before_script
Runs after before_script.
Parameters
----------
Expand Down
12 changes: 5 additions & 7 deletions src/tmuxp/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def tmuxp_echo(
log_level: str = "INFO",
style_log: bool = False,
) -> None:
"""
Combines logging.log and click.echo
"""
"""Combines logging.log and click.echo."""
if message is None:
return

Expand All @@ -45,7 +43,7 @@ def prompt(
https://github.com/techniq/flask-script/blob/master/LICENSE
:param name: prompt text
:param default: default value if no input provided.
:rtype: string
:rtype: string.
"""
_prompt = name + (default and " [%s]" % default or "")
_prompt += name.endswith("?") and " " or ": "
Expand Down Expand Up @@ -75,7 +73,7 @@ def prompt_bool(
:param default: default value if no input provided.
:param yes_choices: default 'y', 'yes', '1', 'on', 'true', 't'
:param no_choices: default 'n', 'no', '0', 'off', 'false', 'f'
:rtype: bool
:rtype: bool.
"""
yes_choices = yes_choices or ("y", "yes", "1", "on", "true", "t")
no_choices = no_choices or ("n", "no", "0", "off", "false", "f")
Expand Down Expand Up @@ -117,7 +115,7 @@ def prompt_choices(
single strings or (key, value) tuples.
:param default: default value if no input provided.
:param no_choice: acceptable list of strings for "null choice"
:rtype: str
:rtype: str.
"""
_choices: t.List[str] = []
options: t.List[str] = []
Expand Down Expand Up @@ -202,7 +200,7 @@ def style(
strikethrough: t.Optional[bool] = None,
reset: bool = True,
) -> str:
"""Credit: click"""
"""Credit: click."""
if not isinstance(text, str):
text = str(text)

Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _from_file(cls, path: pathlib.Path) -> t.Dict[str, t.Any]:

@classmethod
def from_file(cls, path: pathlib.Path) -> "ConfigReader":
r"""Load data from file path
r"""Load data from file path.
**YAML file**
Expand Down
8 changes: 2 additions & 6 deletions src/tmuxp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ def __init__(self, **kwargs: "Unpack[PluginConfigSchema]") -> None:
self._version_check()

def _version_check(self) -> None:
"""
Check all dependency versions for compatibility.
"""
"""Check all dependency versions for compatibility."""
for dep, constraints in self.version_constraints.items():
assert isinstance(constraints, dict)
try:
Expand All @@ -192,9 +190,7 @@ def _pass_version_check(
vmax: t.Optional[str],
incompatible: t.List[t.Union[t.Any, str]],
) -> bool:
"""
Provide affirmative if version compatibility is correct.
"""
"""Provide affirmative if version compatibility is correct."""
if vmin and version < Version(vmin):
return False
if vmax and version > Version(vmax):
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def launch_ptpython() -> None:


def get_ptipython(options: "LaunchOptionalImports", vi_mode: bool = False) -> t.Any:
"""Based on django-extensions
"""Based on django-extensions.
Run renamed to launch, get_imported_objects renamed to get_launch_args
"""
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Internal :term:`type annotations <annotation>`
"""Internal :term:`type annotations <annotation>`.
Notes
-----
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def oh_my_zsh_auto_title() -> None:


def get_current_pane(server: "Server") -> t.Optional["Pane"]:
"""Return Pane if one found in env"""
"""Return Pane if one found in env."""
if os.getenv("TMUX_PANE") is not None:
try:
return next(p for p in server.panes if p.pane_id == os.getenv("TMUX_PANE"))
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/pluginsystem/partials/_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Internal, :const:`typing.TYPE_CHECKING` guarded :term:`type annotations <annotation>`
"""Internal, :const:`typing.TYPE_CHECKING` guarded :term:`type annotations <annotation>`.
These are _not_ to be imported at runtime as `typing_extensions` is not
bundled with tmuxp. Usage example:
Expand All @@ -15,7 +15,7 @@


class PluginTestConfigSchema(TypedDict):
"""Same as PluginConfigSchema, but with tmux, libtmux, and tmuxp version"""
"""Same as PluginConfigSchema, but with tmux, libtmux, and tmuxp version."""

tmux_version: NotRequired[str]
libtmux_version: NotRequired[str]
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
def get_workspace_file(
_file: t.Union[str, pathlib.Path],
) -> pathlib.Path:
"""Return fixture data, relative to __file__"""
"""Return fixture data, relative to __file__."""
if isinstance(_file, str):
_file = pathlib.Path(_file)

return FIXTURE_PATH / _file


def read_workspace_file(_file: t.Union[pathlib.Path, str]) -> str:
"""Return fixture data, relative to __file__"""
"""Return fixture data, relative to __file__."""
if isinstance(_file, str):
_file = pathlib.Path(_file)

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_kills_session(server: Server) -> None:

@pytest.mark.flaky(reruns=5)
def test_if_session_killed_before(server: Server) -> None:
"""Handles situation where session already closed within context"""
"""Handles situation where session already closed within context."""
server = server
session_name = get_test_session_name(server=server)

Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.fixture
def config_fixture() -> WorkspaceTestData:
"""Deferred import of tmuxp.tests.fixtures.*
"""Deferred import of tmuxp.tests.fixtures.*.
pytest setup (conftest.py) patches os.environ["HOME"], delay execution of
os.path.expanduser until here.
Expand Down

0 comments on commit 5aa4487

Please sign in to comment.