Skip to content

Commit

Permalink
chore(ruff): fixes from ruff 0.4.5
Browse files Browse the repository at this point in the history
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes --ignore T201 --ignore F401 --ignore PT014 --ignore RUF100; ruff format .

Fixed 29 errors:
- conftest.py:
    1 × UP037 (quoted-annotation)
- src/tmuxp/_internal/config_reader.py:
    1 × UP037 (quoted-annotation)
- src/tmuxp/cli/convert.py:
    1 × UP037 (quoted-annotation)
- src/tmuxp/cli/debug_info.py:
    3 × COM812 (missing-trailing-comma)
- src/tmuxp/cli/freeze.py:
    1 × UP037 (quoted-annotation)
    1 × COM812 (missing-trailing-comma)
- src/tmuxp/cli/load.py:
    1 × COM812 (missing-trailing-comma)
- src/tmuxp/plugin.py:
    1 × UP037 (quoted-annotation)
- src/tmuxp/shell.py:
    6 × PGH004 (blanket-noqa)
- src/tmuxp/util.py:
    1 × PGH004 (blanket-noqa)
- src/tmuxp/workspace/builder.py:
    1 × UP037 (quoted-annotation)
- tests/fixtures/pluginsystem/partials/all_pass.py:
    1 × UP037 (quoted-annotation)
- tests/fixtures/pluginsystem/partials/libtmux_version_fail.py:
    3 × UP037 (quoted-annotation)
- tests/fixtures/pluginsystem/partials/tmux_version_fail.py:
    3 × UP037 (quoted-annotation)
- tests/fixtures/pluginsystem/partials/tmuxp_version_fail.py:
    3 × UP037 (quoted-annotation)
- tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_fail/tmuxp_test_plugin_fail/plugin.py:
    1 × UP037 (quoted-annotation)
  • Loading branch information
tony committed May 25, 2024
1 parent e2035bd commit 18e74b5
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def add_doctest_fixtures(
"""Harness pytest fixtures to doctests namespace."""
if isinstance(request._pyfuncitem, DoctestItem) and shutil.which("tmux"):
doctest_namespace["server"] = request.getfixturevalue("server")
session: "Session" = request.getfixturevalue("session")
session: Session = request.getfixturevalue("session")
doctest_namespace["session"] = session
doctest_namespace["window"] = session.active_window
doctest_namespace["pane"] = session.active_pane
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/_internal/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _from_file(cls, path: pathlib.Path) -> t.Dict[str, t.Any]:
content = path.open().read()

if path.suffix in {".yaml", ".yml"}:
fmt: "FormatLiteral" = "yaml"
fmt: FormatLiteral = "yaml"
elif path.suffix == ".json":
fmt = "json"
else:
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def command_convert(

_, ext = os.path.splitext(workspace_file)
ext = ext.lower()
to_filetype: "AllowedFileTypes"
to_filetype: AllowedFileTypes
if ext == ".json":
to_filetype = "yaml"
elif ext in {".yaml", ".yml"}:
Expand Down
6 changes: 3 additions & 3 deletions src/tmuxp/cli/debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def format_tmux_resp(std_resp: tmux_cmd) -> str:
f"version: {platform.version()}",
],
),
)
),
),
output_break(),
"python version: {}".format(" ".join(sys.version.split("\n"))),
Expand All @@ -78,10 +78,10 @@ def format_tmux_resp(std_resp: tmux_cmd) -> str:
"tmux windows:\n{}".format(format_tmux_resp(tmux_cmd("list-windows"))),
"tmux panes:\n{}".format(format_tmux_resp(tmux_cmd("list-panes"))),
"tmux global options:\n{}".format(
format_tmux_resp(tmux_cmd("show-options", "-g"))
format_tmux_resp(tmux_cmd("show-options", "-g")),
),
"tmux window options:\n{}".format(
format_tmux_resp(tmux_cmd("show-window-options", "-g"))
format_tmux_resp(tmux_cmd("show-window-options", "-g")),
),
]

Expand Down
4 changes: 2 additions & 2 deletions src/tmuxp/cli/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def command_freeze(
dest = os.path.abspath(os.path.relpath(os.path.expanduser(dest)))
workspace_format = args.workspace_format

valid_workspace_formats: t.List["CLIOutputFormatLiteral"] = ["json", "yaml"]
valid_workspace_formats: t.List[CLIOutputFormatLiteral] = ["json", "yaml"]

def is_valid_ext(stem: t.Optional[str]) -> "TypeGuard[CLIOutputFormatLiteral]":
return stem in valid_workspace_formats
Expand All @@ -186,7 +186,7 @@ def extract_workspace_format(
if not is_valid_ext(workspace_format):
_workspace_format = prompt_choices(
"Couldn't ascertain one of [{}] from file name. Convert to".format(
", ".join(valid_workspace_formats)
", ".join(valid_workspace_formats),
),
choices=t.cast(t.List[str], valid_workspace_formats),
default="yaml",
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def load_workspace(
answer_yes
or prompt_yes_no(
"{} is already running. Attach?".format(
style(session_name, fg="green")
style(session_name, fg="green"),
),
default=True,
)
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, **kwargs: "Unpack[PluginConfigSchema]") -> None:
self.libtmux_version = libtmux.__about__.__version__
self.tmuxp_version = Version(__version__)

self.version_constraints: "TmuxpPluginVersionConstraints" = {
self.version_constraints: TmuxpPluginVersionConstraints = {
"tmux": {
"version": self.tmux_version,
"vmin": config["tmux_min_version"],
Expand Down
12 changes: 6 additions & 6 deletions src/tmuxp/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class LaunchImports(t.TypedDict):
def has_ipython() -> bool:
"""Return True if ipython is installed."""
try:
from IPython import start_ipython # NOQA F841
from IPython import start_ipython # NOQA: F841
except ImportError:
try:
from IPython.Shell import IPShell # NOQA F841
from IPython.Shell import IPShell # NOQA: F841
except ImportError:
return False

Expand All @@ -67,7 +67,7 @@ def has_ptpython() -> bool:
from ptpython.repl import embed, run_config # F841
except ImportError:
try:
from prompt_toolkit.contrib.repl import embed, run_config # NOQA F841
from prompt_toolkit.contrib.repl import embed, run_config # NOQA: F841
except ImportError:
return False

Expand All @@ -81,8 +81,8 @@ def has_ptipython() -> bool:
from ptpython.repl import run_config # F841
except ImportError:
try:
from prompt_toolkit.contrib.ipython import embed # NOQA F841
from prompt_toolkit.contrib.repl import run_config # NOQA F841
from prompt_toolkit.contrib.ipython import embed # NOQA: F841
from prompt_toolkit.contrib.repl import run_config # NOQA: F841
except ImportError:
return False

Expand All @@ -92,7 +92,7 @@ def has_ptipython() -> bool:
def has_bpython() -> bool:
"""Return True if bpython is installed."""
try:
from bpython import embed # NOQA F841
from bpython import embed # NOQA: F841
except ImportError:
return False
return True
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def oh_my_zsh_auto_title() -> None:
if (
"SHELL" in os.environ
and "zsh" in os.environ.get("SHELL", "")
and os.path.exists(os.path.expanduser("~/.oh-my-zsh")) # NOQA PTH110, PTH111
and os.path.exists(os.path.expanduser("~/.oh-my-zsh")) # NOQA: PTH110, PTH111
and (
"DISABLE_AUTO_TITLE" not in os.environ
or os.environ.get("DISABLE_AUTO_TITLE") == "false"
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/workspace/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def build(self, session: t.Optional[Session] = None, append: bool = False) -> No

assert session.server is not None

self.server: "Server" = session.server
self.server: Server = session.server
assert self.server.sessions is not None
assert self.server.has_session(session.name)
assert session.id
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/pluginsystem/partials/all_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AllVersionPassPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin with config constraints guaranteed to validate."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmuxp-plugin-my-tmuxp-plugin",
"tmux_min_version": "1.8",
"tmux_max_version": "100.0",
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/pluginsystem/partials/libtmux_version_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LibtmuxVersionFailMinPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when libtmux below minimum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "libtmux-min-version-fail",
"libtmux_min_version": "0.8.3",
"libtmux_version": "0.7.0",
Expand All @@ -24,7 +24,7 @@ class LibtmuxVersionFailMaxPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when libtmux above maximum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "libtmux-max-version-fail",
"libtmux_max_version": "3.0",
"libtmux_version": "3.5",
Expand All @@ -36,7 +36,7 @@ class LibtmuxVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when libtmux version constraint is invalid."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "libtmux-incompatible-version-fail",
"libtmux_version_incompatible": ["0.7.1"],
"libtmux_version": "0.7.1",
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/pluginsystem/partials/tmux_version_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TmuxVersionFailMinPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmux below minimum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmux-min-version-fail",
"tmux_min_version": "1.8",
"tmux_version": "1.7",
Expand All @@ -24,7 +24,7 @@ class TmuxVersionFailMaxPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmux above maximum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmux-max-version-fail",
"tmux_max_version": "3.0",
"tmux_version": "3.5",
Expand All @@ -36,7 +36,7 @@ class TmuxVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmux version constraint is invalid."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmux-incompatible-version-fail",
"tmux_version_incompatible": ["2.3"],
"tmux_version": "2.3",
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/pluginsystem/partials/tmuxp_version_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TmuxpVersionFailMinPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmuxp below minimum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmuxp-min-version-fail",
"tmuxp_min_version": "1.7.0",
"tmuxp_version": "1.6.3",
Expand All @@ -24,7 +24,7 @@ class TmuxpVersionFailMaxPlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmuxp above maximum version constraint."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmuxp-max-version-fail",
"tmuxp_max_version": "2.0.0",
"tmuxp_version": "2.5",
Expand All @@ -36,7 +36,7 @@ class TmuxpVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
"""Tmuxp plugin that fails when tmuxp version constraint is invalid."""

def __init__(self) -> None:
config: "PluginTestConfigSchema" = {
config: PluginTestConfigSchema = {
"plugin_name": "tmuxp-incompatible-version-fail",
"tmuxp_version_incompatible": ["1.5.0"],
"tmuxp_version": "1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PluginFailVersion(TmuxpPlugin):
"""A tmuxp plugin that is doomed to fail. DOOMED."""

def __init__(self) -> None:
config: "PluginConfigSchema" = {
config: PluginConfigSchema = {
"plugin_name": "tmuxp-plugin-fail-version",
"tmuxp_max_version": "0.0.0",
}
Expand Down

0 comments on commit 18e74b5

Please sign in to comment.