diff --git a/CHANGES b/CHANGES index 8a5937810b3..ca37b9a30e9 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,25 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force +### Development + +- Aggressive automated lint fixes via `ruff` (#922) + + via ruff v0.3.4, all automated lint fixes, including unsafe and previews were applied: + + ```sh + ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; ruff format . + ``` + + Branches were treated with: + + ```sh + git rebase \ + --strategy-option=theirs \ + --exec 'poetry run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; poetry run ruff format .; git add src tests; git commit --amend --no-edit' \ + origin/master + ``` + ## tmuxp 1.44.0 (2024-03-24) ### Breaking changes diff --git a/conftest.py b/conftest.py index e3a6be065fd..72f16c6d524 100644 --- a/conftest.py +++ b/conftest.py @@ -47,7 +47,7 @@ def home_path_default(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path) monkeypatch.setenv("HOME", str(user_path)) -@pytest.fixture +@pytest.fixture() def tmuxp_configdir(user_path: pathlib.Path) -> pathlib.Path: """Ensure and return tmuxp config directory.""" xdg_config_dir = user_path / ".config" @@ -58,7 +58,7 @@ def tmuxp_configdir(user_path: pathlib.Path) -> pathlib.Path: return tmuxp_configdir -@pytest.fixture +@pytest.fixture() def tmuxp_configdir_default( monkeypatch: pytest.MonkeyPatch, tmuxp_configdir: pathlib.Path, @@ -68,7 +68,7 @@ def tmuxp_configdir_default( assert get_workspace_dir() == str(tmuxp_configdir) -@pytest.fixture(scope="function") +@pytest.fixture() def monkeypatch_plugin_test_packages(monkeypatch: pytest.MonkeyPatch) -> None: """Monkeypatch tmuxp plugin fixtures to python path.""" paths = [ @@ -83,14 +83,14 @@ def monkeypatch_plugin_test_packages(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.syspath_prepend(str(pathlib.Path(path).resolve())) -@pytest.fixture(scope="function") +@pytest.fixture() def session_params(session_params: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]: """Terminal-friendly tmuxp session_params for dimensions.""" session_params.update({"x": 800, "y": 600}) return session_params -@pytest.fixture(scope="function") +@pytest.fixture() def socket_name(request: pytest.FixtureRequest) -> str: """Random socket name for tmuxp.""" return "tmuxp_test%s" % next(namer) diff --git a/docs/_ext/aafig.py b/docs/_ext/aafig.py index 35e3cbcdde4..0c49b621512 100644 --- a/docs/_ext/aafig.py +++ b/docs/_ext/aafig.py @@ -12,6 +12,7 @@ :license: BOLA, see LICENSE for details """ +import locale import logging import posixpath import typing as t @@ -91,7 +92,7 @@ def run(self) -> t.List[nodes.Node]: if v is None: v = True # convert percentage to float - if k == "scale" or k == "aspect": + if k in {"scale", "aspect"}: v = float(v) / 100.0 aafig_options[k] = v del self.options[k] @@ -108,7 +109,7 @@ def render_aafig_images(app: "Sphinx", doctree: nodes.Node) -> None: format_map = app.builder.config.aafig_format merge_dict(format_map, DEFAULT_FORMATS) if aafigure is None: - logger.warn( + logger.warning( "aafigure module not installed, ASCII art images " "will be rendered as literal text", ) @@ -124,7 +125,7 @@ def render_aafig_images(app: "Sphinx", doctree: nodes.Node) -> None: if _format in format_map: options["format"] = format_map[_format] else: - logger.warn( + logger.warning( 'unsupported builder format "%s", please ' "add a custom entry in aafig_format config " "option for this builder" % _format, @@ -135,9 +136,9 @@ def render_aafig_images(app: "Sphinx", doctree: nodes.Node) -> None: img.replace_self(nodes.literal_block(text, text)) continue try: - fname, outfn, _id, extra = render_aafigure(app, text, options) + fname, _outfn, _id, extra = render_aafigure(app, text, options) except AafigError as exc: - logger.warn("aafigure error: " + str(exc)) + logger.warning("aafigure error: " + str(exc)) img.replace_self(nodes.literal_block(text, text)) continue img["uri"] = fname @@ -162,7 +163,7 @@ def render_aafigure( ) -> t.Tuple[str, str, t.Optional[str], t.Optional[str]]: """Render an ASCII art figure into the requested format output file.""" if aafigure is None: - raise AafigureNotInstalled() + raise AafigureNotInstalled fname = get_basename(text, options) fname = "{}.{}".format(get_basename(text, options), options["format"]) @@ -174,7 +175,7 @@ def render_aafigure( else: # Non-HTML if app.builder.format != "latex": - logger.warn( + logger.warning( "aafig: the builder format %s is not officially " "supported, aafigure images could not work. " "Please report problems and working builder to " @@ -191,10 +192,12 @@ def render_aafigure( f = None try: try: - with open(metadata_fname) as f: + with open( + metadata_fname, encoding=locale.getpreferredencoding(False) + ) as f: extra = f.read() except Exception as e: - raise AafigError() from e + raise AafigError from e finally: if f is not None: f.close() @@ -213,7 +216,9 @@ def render_aafigure( extra = None if options["format"].lower() == "svg": extra = visitor.get_size_attrs() - with open(metadata_fname, "w") as f: + with open( + metadata_fname, "w", encoding=locale.getpreferredencoding(False) + ) as f: f.write(extra) return relfn, outfn, None, extra diff --git a/docs/conf.py b/docs/conf.py index 3926d58067f..0d4e7f3ae76 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -202,15 +202,14 @@ def linkcode_resolve(domain: str, info: t.Dict[str, str]) -> t.Union[None, str]: fn, linespec, ) - else: - return "{}/blob/v{}/{}/{}/{}{}".format( - about["__github__"], - about["__version__"], - "src", - about["__package_name__"], - fn, - linespec, - ) + return "{}/blob/v{}/{}/{}/{}{}".format( + about["__github__"], + about["__version__"], + "src", + about["__package_name__"], + fn, + linespec, + ) def remove_tabs_js(app: "Sphinx", exc: Exception) -> None: diff --git a/src/tmuxp/_internal/config_reader.py b/src/tmuxp/_internal/config_reader.py index dd381f3731b..62e6c1e44e8 100644 --- a/src/tmuxp/_internal/config_reader.py +++ b/src/tmuxp/_internal/config_reader.py @@ -45,11 +45,10 @@ def _load(fmt: "FormatLiteral", content: str) -> t.Dict[str, t.Any]: Loader=yaml.SafeLoader, ), ) - elif fmt == "json": + if fmt == "json": return t.cast(t.Dict[str, t.Any], json.loads(content)) - else: - msg = f"{fmt} not supported in configuration" - raise NotImplementedError(msg) + msg = f"{fmt} not supported in configuration" + raise NotImplementedError(msg) @classmethod def load(cls, fmt: "FormatLiteral", content: str) -> "ConfigReader": @@ -107,7 +106,7 @@ def _from_file(cls, path: pathlib.Path) -> t.Dict[str, t.Any]: assert isinstance(path, pathlib.Path) content = path.open().read() - if path.suffix in [".yaml", ".yml"]: + if path.suffix in {".yaml", ".yml"}: fmt: "FormatLiteral" = "yaml" elif path.suffix == ".json": fmt = "json" @@ -182,14 +181,13 @@ def _dump( default_flow_style=False, Dumper=yaml.SafeDumper, ) - elif fmt == "json": + if fmt == "json": return json.dumps( content, indent=2, ) - else: - msg = f"{fmt} not supported in config" - raise NotImplementedError(msg) + msg = f"{fmt} not supported in config" + raise NotImplementedError(msg) def dump(self, fmt: "FormatLiteral", indent: int = 2, **kwargs: t.Any) -> str: r"""Dump via ConfigReader instance. diff --git a/src/tmuxp/cli/__init__.py b/src/tmuxp/cli/__init__.py index e1a0646da5b..e1ee765a774 100644 --- a/src/tmuxp/cli/__init__.py +++ b/src/tmuxp/cli/__init__.py @@ -11,9 +11,10 @@ from libtmux.common import has_minimum_version from libtmux.exc import TmuxCommandNotFound -from .. import exc -from ..__about__ import __version__ -from ..log import setup_logger +from tmuxp import exc +from tmuxp.__about__ import __version__ +from tmuxp.log import setup_logger + from .convert import command_convert, create_convert_subparser from .debug_info import command_debug_info, create_debug_info_subparser from .edit import command_edit, create_edit_subparser @@ -141,7 +142,7 @@ def cli(_args: t.Optional[t.List[str]] = None) -> None: if args.subparser_name is None: parser.print_help() return - elif args.subparser_name == "load": + if args.subparser_name == "load": command_load( args=CLILoadNamespace(**vars(args)), parser=parser, @@ -156,7 +157,7 @@ def cli(_args: t.Optional[t.List[str]] = None) -> None: if import_subparser_name is None: parser.print_help() return - elif import_subparser_name == "teamocil": + if import_subparser_name == "teamocil": command_import_teamocil( workspace_file=args.workspace_file, parser=parser, diff --git a/src/tmuxp/cli/convert.py b/src/tmuxp/cli/convert.py index 8479087f64a..4623b2bb205 100644 --- a/src/tmuxp/cli/convert.py +++ b/src/tmuxp/cli/convert.py @@ -1,14 +1,15 @@ """CLI for ``tmuxp convert`` subcommand.""" import argparse +import locale import os import pathlib import typing as t +from tmuxp import exc from tmuxp._internal.config_reader import ConfigReader from tmuxp.workspace.finders import find_workspace_file, get_workspace_dir -from .. import exc from .utils import prompt_yes_no if t.TYPE_CHECKING: @@ -70,7 +71,7 @@ def command_convert( to_filetype: "AllowedFileTypes" if ext == ".json": to_filetype = "yaml" - elif ext in [".yaml", ".yml"]: + elif ext in {".yaml", ".yml"}: to_filetype = "json" else: raise ConvertUnknownFileType(ext) @@ -92,6 +93,6 @@ def command_convert( answer_yes = True if answer_yes: - with open(newfile, "w") as buf: + with open(newfile, "w", encoding=locale.getpreferredencoding(False)) as buf: buf.write(new_workspace) print(f"New workspace file saved to <{newfile}>.") diff --git a/src/tmuxp/cli/debug_info.py b/src/tmuxp/cli/debug_info.py index a37f5f0104a..29224362636 100644 --- a/src/tmuxp/cli/debug_info.py +++ b/src/tmuxp/cli/debug_info.py @@ -12,7 +12,8 @@ from libtmux.__about__ import __version__ as libtmux_version from libtmux.common import get_version, tmux_cmd -from ..__about__ import __version__ +from tmuxp.__about__ import __version__ + from .utils import tmuxp_echo tmuxp_path = pathlib.Path(__file__).parent.parent diff --git a/src/tmuxp/cli/freeze.py b/src/tmuxp/cli/freeze.py index cb4d31e754f..d5e1c027a3c 100644 --- a/src/tmuxp/cli/freeze.py +++ b/src/tmuxp/cli/freeze.py @@ -1,6 +1,7 @@ """CLI for ``tmuxp freeze`` subcommand.""" import argparse +import locale import os import pathlib import sys @@ -8,12 +9,12 @@ from libtmux.server import Server +from tmuxp import exc, util from tmuxp._internal.config_reader import ConfigReader from tmuxp.exc import TmuxpException +from tmuxp.workspace import freezer from tmuxp.workspace.finders import get_workspace_dir -from .. import exc, util -from ..workspace import freezer from .utils import prompt, prompt_choices, prompt_yes_no if t.TYPE_CHECKING: @@ -112,7 +113,7 @@ def command_freeze( session = util.get_session(server) if not session: - raise exc.SessionNotFound() + raise exc.SessionNotFound except TmuxpException as e: print(e) return @@ -206,7 +207,7 @@ def extract_workspace_format( destdir = os.path.dirname(dest) if not os.path.isdir(destdir): os.makedirs(destdir) - with open(dest, "w") as buf: + with open(dest, "w", encoding=locale.getpreferredencoding(False)) as buf: buf.write(workspace) if not args.quiet: diff --git a/src/tmuxp/cli/import_config.py b/src/tmuxp/cli/import_config.py index dec7f2e5262..63204789347 100644 --- a/src/tmuxp/cli/import_config.py +++ b/src/tmuxp/cli/import_config.py @@ -1,15 +1,16 @@ """CLI for ``tmuxp shell`` subcommand.""" import argparse +import locale import os import pathlib import sys import typing as t from tmuxp._internal.config_reader import ConfigReader +from tmuxp.workspace import importers from tmuxp.workspace.finders import find_workspace_file -from ..workspace import importers from .utils import prompt, prompt_choices, prompt_yes_no, tmuxp_echo @@ -172,7 +173,7 @@ def import_config( if prompt_yes_no("Save to %s?" % dest_path): dest = dest_path - with open(dest, "w") as buf: + with open(dest, "w", encoding=locale.getpreferredencoding(False)) as buf: buf.write(new_config) tmuxp_echo("Saved to %s." % dest) diff --git a/src/tmuxp/cli/load.py b/src/tmuxp/cli/load.py index f71976ad1fd..708c8e4a430 100644 --- a/src/tmuxp/cli/load.py +++ b/src/tmuxp/cli/load.py @@ -13,13 +13,13 @@ from libtmux.server import Server from libtmux.session import Session +from tmuxp import exc, log, util +from tmuxp._internal import config_reader from tmuxp.types import StrPath +from tmuxp.workspace import loader +from tmuxp.workspace.builder import WorkspaceBuilder +from tmuxp.workspace.finders import find_workspace_file, get_workspace_dir -from .. import exc, log, util -from .._internal import config_reader -from ..workspace import loader -from ..workspace.builder import WorkspaceBuilder -from ..workspace.finders import find_workspace_file, get_workspace_dir from .utils import prompt_choices, prompt_yes_no, style, tmuxp_echo if t.TYPE_CHECKING: @@ -93,8 +93,9 @@ def set_layout_hook(session: Session, hook_name: str) -> None: hook_cmd.append("selectw -p") # unset the hook immediately after executing - hook_cmd.append(f"set-hook -u -t {session.id} {hook_name}") - hook_cmd.append(f"selectw -t {active_window.id}") + hook_cmd.extend( + (f"set-hook -u -t {session.id} {hook_name}", f"selectw -t {active_window.id}") + ) # join the hook's commands with semicolons _hook_cmd = "{}".format("; ".join(hook_cmd)) @@ -441,7 +442,7 @@ def load_workspace( return _setup_plugins(builder) # append and answer_yes have no meaning if specified together - elif answer_yes: + if answer_yes: _load_attached(builder, detached) return _setup_plugins(builder) diff --git a/src/tmuxp/cli/shell.py b/src/tmuxp/cli/shell.py index 1d5e95cea4f..eee241a0322 100644 --- a/src/tmuxp/cli/shell.py +++ b/src/tmuxp/cli/shell.py @@ -7,8 +7,8 @@ from libtmux.server import Server -from .. import util -from .._compat import PY3, PYMINOR +from tmuxp import util +from tmuxp._compat import PY3, PYMINOR if t.TYPE_CHECKING: from typing_extensions import TypeAlias @@ -191,24 +191,23 @@ def command_shell( if args.command is not None: exec(args.command) + elif args.shell == "pdb" or ( + os.getenv("PYTHONBREAKPOINT") and PY3 and PYMINOR >= 7 + ): + from tmuxp._compat import breakpoint as tmuxp_breakpoint + + tmuxp_breakpoint() + return else: - if args.shell == "pdb" or ( - os.getenv("PYTHONBREAKPOINT") and PY3 and PYMINOR >= 7 - ): - from tmuxp._compat import breakpoint as tmuxp_breakpoint - - tmuxp_breakpoint() - return - else: - from ..shell import launch - - launch( - shell=args.shell, - use_pythonrc=args.use_pythonrc, # shell: code - use_vi_mode=args.use_vi_mode, # shell: ptpython, ptipython - # tmux environment / libtmux variables - server=server, - session=session, - window=window, - pane=pane, - ) + from tmuxp.shell import launch + + launch( + shell=args.shell, + use_pythonrc=args.use_pythonrc, # shell: code + use_vi_mode=args.use_vi_mode, # shell: ptpython, ptipython + # tmux environment / libtmux variables + server=server, + session=session, + window=window, + pane=pane, + ) diff --git a/src/tmuxp/cli/utils.py b/src/tmuxp/cli/utils.py index c5b21194d62..c143042de56 100644 --- a/src/tmuxp/cli/utils.py +++ b/src/tmuxp/cli/utils.py @@ -4,7 +4,7 @@ import re import typing as t -from .. import log +from tmuxp import log if t.TYPE_CHECKING: from typing_extensions import TypeAlias @@ -56,8 +56,8 @@ def prompt( `flask-script `_. See the `flask-script license `_. """ - _prompt = name + (default and " [%s]" % default or "") - _prompt += name.endswith("?") and " " or ": " + _prompt = name + ((default and " [%s]" % default) or "") + _prompt += (name.endswith("?") and " ") or ": " while True: rv = input(_prompt) or default try: @@ -107,7 +107,7 @@ def prompt_bool( prompt_choice = "y/N" _prompt = name + " [%s]" % prompt_choice - _prompt += name.endswith("?") and " " or ": " + _prompt += (name.endswith("?") and " ") or ": " while True: rv = input(_prompt) @@ -115,7 +115,7 @@ def prompt_bool( return default if rv.lower() in yes_choices: return True - elif rv.lower() in no_choices: + if rv.lower() in no_choices: return False diff --git a/src/tmuxp/log.py b/src/tmuxp/log.py index 5ee29c27378..b841d340add 100644 --- a/src/tmuxp/log.py +++ b/src/tmuxp/log.py @@ -193,9 +193,7 @@ def debug_log_template( + "%(lineno)d" ) - tpl = reset + levelname + asctime + name + module_funcName + lineno + reset - - return tpl + return reset + levelname + asctime + name + module_funcName + lineno + reset class DebugLogFormatter(LogFormatter): diff --git a/src/tmuxp/plugin.py b/src/tmuxp/plugin.py index 680a34172b7..1f8ad53e658 100644 --- a/src/tmuxp/plugin.py +++ b/src/tmuxp/plugin.py @@ -213,10 +213,7 @@ def _pass_version_check( return False if vmax and version > Version(vmax): return False - if version in incompatible: - return False - - return True + return version not in incompatible def before_workspace_builder(self, session: "Session") -> None: """ diff --git a/src/tmuxp/shell.py b/src/tmuxp/shell.py index 33e8657b474..45496db90f3 100644 --- a/src/tmuxp/shell.py +++ b/src/tmuxp/shell.py @@ -102,11 +102,11 @@ def detect_best_shell() -> "CLIShellLiteral": """Return the best, most feature-rich shell available.""" if has_ptipython(): return "ptipython" - elif has_ptpython(): + if has_ptpython(): return "ptpython" - elif has_ipython(): + if has_ipython(): return "ipython" - elif has_bpython(): + if has_bpython(): return "bpython" return "code" diff --git a/src/tmuxp/types.py b/src/tmuxp/types.py index 6d05b258c02..d94328dfb3c 100644 --- a/src/tmuxp/types.py +++ b/src/tmuxp/types.py @@ -7,8 +7,10 @@ .. _typeshed's: https://github.com/python/typeshed/blob/9687d5/stdlib/_typeshed/__init__.pyi#L98 """ # E501 -from os import PathLike -from typing import Union +from typing import TYPE_CHECKING, Union + +if TYPE_CHECKING: + from os import PathLike StrPath = Union[str, "PathLike[str]"] """:class:`os.PathLike` or :class:`str`""" diff --git a/src/tmuxp/util.py b/src/tmuxp/util.py index 940d58db8f7..2cab9fbbbee 100644 --- a/src/tmuxp/util.py +++ b/src/tmuxp/util.py @@ -51,16 +51,14 @@ def run_before_script( os.path.abspath(script_file), # NOQA: PTH100 stderr_str, ) - else: - return proc.returncode except OSError as e: if e.errno == 2: raise exc.BeforeLoadScriptNotExists( e, os.path.abspath(script_file), # NOQA: PTH100 ) from e - else: - raise + raise + return proc.returncode def oh_my_zsh_auto_title() -> None: @@ -118,7 +116,7 @@ def get_session( except Exception as e: if session_name: raise exc.SessionNotFound(session_name) from e - raise exc.SessionNotFound() from e + raise exc.SessionNotFound from e assert session is not None return session @@ -140,9 +138,9 @@ def get_window( except Exception as e: if window_name: raise exc.WindowNotFound(window_target=window_name) from e - elif current_pane: + if current_pane: raise exc.WindowNotFound(window_target=str(current_pane)) from e - raise exc.WindowNotFound() from e + raise exc.WindowNotFound from e assert window is not None return window @@ -162,6 +160,6 @@ def get_pane(window: "Window", current_pane: t.Optional["Pane"] = None) -> "Pane if pane is None: if current_pane: raise exc.PaneNotFound(str(current_pane)) - raise exc.PaneNotFound() + raise exc.PaneNotFound return pane diff --git a/src/tmuxp/workspace/builder.py b/src/tmuxp/workspace/builder.py index 02f9efa517d..75008d0b77a 100644 --- a/src/tmuxp/workspace/builder.py +++ b/src/tmuxp/workspace/builder.py @@ -11,8 +11,8 @@ from libtmux.session import Session from libtmux.window import Window -from .. import exc -from ..util import get_current_pane, run_before_script +from tmuxp import exc +from tmuxp.util import get_current_pane, run_before_script logger = logging.getLogger(__name__) @@ -159,7 +159,7 @@ def __init__( if plugins is None: plugins = [] if not session_config: - raise exc.EmptyWorkspaceException() + raise exc.EmptyWorkspaceException # validation.validate_schema(session_config) @@ -185,7 +185,7 @@ def __init__( def session(self) -> Session: """Return tmux session using in workspace builder session.""" if self._session is None: - raise exc.SessionMissingWorkspaceException() + raise exc.SessionMissingWorkspaceException return self._session def session_exists(self, session_name: str) -> bool: @@ -224,19 +224,18 @@ def build(self, session: t.Optional[Session] = None, append: bool = False) -> No "WorkspaceBuilder.build requires server to be passed " + "on initialization, or pass in session object to here.", ) - else: - new_session_kwargs = {} - if "start_directory" in self.session_config: - new_session_kwargs["start_directory"] = self.session_config[ - "start_directory" - ] - if has_gte_version("2.6"): - new_session_kwargs["x"] = 800 - new_session_kwargs["y"] = 600 - session = self.server.new_session( - session_name=self.session_config["session_name"], - **new_session_kwargs, - ) + new_session_kwargs = {} + if "start_directory" in self.session_config: + new_session_kwargs["start_directory"] = self.session_config[ + "start_directory" + ] + if has_gte_version("2.6"): + new_session_kwargs["x"] = 800 + new_session_kwargs["y"] = 600 + session = self.server.new_session( + session_name=self.session_config["session_name"], + **new_session_kwargs, + ) assert session is not None assert self.session_config["session_name"] == session.name @@ -462,10 +461,9 @@ def get_pane_start_directory( ) -> t.Optional[str]: if "start_directory" in pane_config: return pane_config["start_directory"] - elif "start_directory" in window_config: + if "start_directory" in window_config: return window_config["start_directory"] - else: - return None + return None def get_pane_shell( pane_config: t.Dict[str, str], @@ -473,10 +471,9 @@ def get_pane_shell( ) -> t.Optional[str]: if "shell" in pane_config: return pane_config["shell"] - elif "window_shell" in window_config: + if "window_shell" in window_config: return window_config["window_shell"] - else: - return None + return None environment = pane_config.get( "environment", @@ -574,7 +571,7 @@ def find_current_attached_session(self) -> Session: current_active_pane = get_current_pane(self.server) if current_active_pane is None: - raise exc.ActiveSessionMissingWorkspaceException() + raise exc.ActiveSessionMissingWorkspaceException return next( ( diff --git a/src/tmuxp/workspace/finders.py b/src/tmuxp/workspace/finders.py index 290f2e4eaf6..51ee0c7d578 100644 --- a/src/tmuxp/workspace/finders.py +++ b/src/tmuxp/workspace/finders.py @@ -67,14 +67,12 @@ def in_dir( if extensions is None: extensions = [".yml", ".yaml", ".json"] - workspace_files = [ + return [ filename for filename in os.listdir(workspace_dir) if is_workspace_file(filename, extensions) and not filename.startswith(".") ] - return workspace_files - def in_cwd() -> t.List[str]: """ @@ -92,14 +90,12 @@ def in_cwd() -> t.List[str]: >>> sorted(in_cwd()) ['.tmuxp.json', '.tmuxp.yaml'] """ - workspace_files = [ + return [ filename for filename in os.listdir(os.getcwd()) if filename.startswith(".tmuxp") and is_workspace_file(filename) ] - return workspace_files - def get_workspace_dir() -> str: """ diff --git a/src/tmuxp/workspace/freezer.py b/src/tmuxp/workspace/freezer.py index 0fb365802a1..e782ccec2c2 100644 --- a/src/tmuxp/workspace/freezer.py +++ b/src/tmuxp/workspace/freezer.py @@ -112,9 +112,8 @@ def filter_interpreters_and_shells(current_cmd: t.Optional[str]) -> bool: if current_cmd: pane_config["shell_command"].append(current_cmd) - else: - if not len(pane_config["shell_command"]): - pane_config = "pane" + elif not len(pane_config["shell_command"]): + pane_config = "pane" window_config["panes"].append(pane_config) diff --git a/src/tmuxp/workspace/importers.py b/src/tmuxp/workspace/importers.py index 9666546bc38..1ae321eb6aa 100644 --- a/src/tmuxp/workspace/importers.py +++ b/src/tmuxp/workspace/importers.py @@ -82,7 +82,7 @@ def import_tmuxinator(workspace_dict: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]: window_dict["panes"] = [v] tmuxp_workspace["windows"].append(window_dict) continue - elif isinstance(v, list): + if isinstance(v, list): window_dict["panes"] = v tmuxp_workspace["windows"].append(window_dict) continue @@ -157,7 +157,7 @@ def import_teamocil(workspace_dict: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]: if "cmd" in p: p["shell_command"] = p.pop("cmd") if "width" in p: - # todo support for height/width + # TODO support for height/width p.pop("width") window_dict["panes"] = w["panes"] diff --git a/src/tmuxp/workspace/loader.py b/src/tmuxp/workspace/loader.py index c9496b4a31b..58da0ee91a2 100644 --- a/src/tmuxp/workspace/loader.py +++ b/src/tmuxp/workspace/loader.py @@ -218,15 +218,14 @@ def trickle(workspace_dict: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]: session_start_directory = session_start_directory if "start_directory" not in window_dict: window_dict["start_directory"] = session_start_directory - else: - if not any( - window_dict["start_directory"].startswith(a) for a in ["~", "/"] - ): - window_start_path = ( - pathlib.Path(session_start_directory) - / window_dict["start_directory"] - ) - window_dict["start_directory"] = str(window_start_path) + elif not any( + window_dict["start_directory"].startswith(a) for a in ["~", "/"] + ): + window_start_path = ( + pathlib.Path(session_start_directory) + / window_dict["start_directory"] + ) + window_dict["start_directory"] = str(window_start_path) # We only need to trickle to the window, workspace builder checks wconf if suppress_history is not None and "suppress_history" not in window_dict: diff --git a/src/tmuxp/workspace/validation.py b/src/tmuxp/workspace/validation.py index e4c7bca5ce3..b200bd63080 100644 --- a/src/tmuxp/workspace/validation.py +++ b/src/tmuxp/workspace/validation.py @@ -2,14 +2,12 @@ import typing as t -from .. import exc +from tmuxp import exc class SchemaValidationError(exc.WorkspaceError): """Tmuxp configuration validation base error.""" - pass - class SessionNameMissingValidationError(SchemaValidationError): """Tmuxp configuration error for session name missing.""" @@ -72,14 +70,14 @@ def validate_schema(workspace_dict: t.Any) -> bool: """ # verify session_name if "session_name" not in workspace_dict: - raise SessionNameMissingValidationError() + raise SessionNameMissingValidationError if "windows" not in workspace_dict: - raise WindowListMissingValidationError() + raise WindowListMissingValidationError for window in workspace_dict["windows"]: if "window_name" not in window: - raise WindowNameMissingValidationError() + raise WindowNameMissingValidationError if "plugins" in workspace_dict and not isinstance(workspace_dict["plugins"], list): raise InvalidPluginsValidationError(plugins=workspace_dict.get("plugins")) diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 6e6cc5bd4e8..ee48809596a 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -7,8 +7,8 @@ import libtmux import pytest -from libtmux.server import Server +from tests.fixtures import utils as test_utils from tmuxp import cli from tmuxp._internal.config_reader import ConfigReader from tmuxp.cli.import_config import get_teamocil_dir, get_tmuxinator_dir @@ -18,10 +18,9 @@ from tmuxp.workspace.builder import WorkspaceBuilder from tmuxp.workspace.finders import find_workspace_file -from ..fixtures import utils as test_utils - if t.TYPE_CHECKING: import _pytest.capture + from libtmux.server import Server def test_creates_config_dir_not_exists(tmp_path: pathlib.Path) -> None: diff --git a/tests/cli/test_convert.py b/tests/cli/test_convert.py index 4661ca99aef..5e792a473ea 100644 --- a/tests/cli/test_convert.py +++ b/tests/cli/test_convert.py @@ -32,7 +32,7 @@ def test_convert( if filename == ".": filename = ".tmuxp.yaml" file_ext = filename.rsplit(".", 1)[-1] - assert file_ext in ["yaml", "yml"], file_ext + assert file_ext in {"yaml", "yml"}, file_ext workspace_file_path = tmp_path / filename workspace_file_path.write_text("\nsession_name: hello\n", encoding="utf-8") oh_my_zsh_path = tmp_path / ".oh-my-zsh" diff --git a/tests/cli/test_freeze.py b/tests/cli/test_freeze.py index 07d95f6b6b6..0dc56c48e6f 100644 --- a/tests/cli/test_freeze.py +++ b/tests/cli/test_freeze.py @@ -6,14 +6,16 @@ import typing as t import pytest -from libtmux.server import Server from tmuxp import cli from tmuxp._internal.config_reader import ConfigReader +if t.TYPE_CHECKING: + from libtmux.server import Server + @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ (["freeze", "myfrozensession"], ["y\n", "./la.yaml\n", "y\n"]), ( # Exists @@ -67,7 +69,7 @@ def test_freeze( @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ ( # Overwrite ["freeze", "mysession", "--force"], diff --git a/tests/cli/test_import.py b/tests/cli/test_import.py index 5723a79a8c2..1e94d4e2ff3 100644 --- a/tests/cli/test_import.py +++ b/tests/cli/test_import.py @@ -7,10 +7,9 @@ import pytest +from tests.fixtures import utils as test_utils from tmuxp import cli -from ..fixtures import utils as test_utils - @pytest.mark.parametrize("cli_args", [(["import"])]) def test_import( @@ -27,7 +26,7 @@ def test_import( @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ ( ["import", "teamocil", "./.teamocil/config.yaml"], @@ -74,7 +73,7 @@ def test_import_teamocil( @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ ( ["import", "tmuxinator", "./.tmuxinator/config.yaml"], diff --git a/tests/cli/test_load.py b/tests/cli/test_load.py index 9c3b22c7411..0a1f0dd05d2 100644 --- a/tests/cli/test_load.py +++ b/tests/cli/test_load.py @@ -12,6 +12,8 @@ from libtmux.session import Session from pytest_mock import MockerFixture +from tests.constants import FIXTURE_PATH +from tests.fixtures import utils as test_utils from tmuxp import cli from tmuxp._internal.config_reader import ConfigReader from tmuxp.cli.load import ( @@ -23,9 +25,6 @@ from tmuxp.workspace import loader from tmuxp.workspace.builder import WorkspaceBuilder -from ..constants import FIXTURE_PATH -from ..fixtures import utils as test_utils - def test_load_workspace( server: "Server", @@ -479,7 +478,7 @@ def test_load_plugins( @pytest.mark.skip("Not sure how to clean up the tmux session this makes") @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ ( ["load", "tests/fixtures/workspace/builder/plugin_versions_fail.yaml"], @@ -503,7 +502,7 @@ def test_load_plugins_version_fail_skip( @pytest.mark.parametrize( - "cli_args,inputs", + ("cli_args", "inputs"), [ ( ["load", "tests/fixtures/workspace/builder/plugin_versions_fail.yaml"], diff --git a/tests/cli/test_shell.py b/tests/cli/test_shell.py index b6ceeceb4ef..39f7e7d6944 100644 --- a/tests/cli/test_shell.py +++ b/tests/cli/test_shell.py @@ -7,11 +7,13 @@ import typing as t import pytest -from libtmux.server import Server from libtmux.session import Session from tmuxp import cli, exc +if t.TYPE_CHECKING: + from libtmux.server import Server + class CLIShellFixture(t.NamedTuple): """Test fixture for tmuxp shell tests.""" @@ -154,7 +156,7 @@ def test_shell( ], ) @pytest.mark.parametrize( - "cli_args,inputs,env,template_ctx,exception,message", + ("cli_args", "inputs", "env", "template_ctx", "exception", "message"), [ ( ["-LDoesNotExist", "-c", "print(str(server.socket_name))"], @@ -256,7 +258,7 @@ def test_shell_target_missing( ], ) @pytest.mark.parametrize( - "cli_args,inputs,env,message", + ("cli_args", "inputs", "env", "message"), [ ( [ diff --git a/tests/fixtures/import_teamocil/layouts.py b/tests/fixtures/import_teamocil/layouts.py index cf114f4eceb..d09e0fbf0a1 100644 --- a/tests/fixtures/import_teamocil/layouts.py +++ b/tests/fixtures/import_teamocil/layouts.py @@ -1,6 +1,6 @@ """Teamocil data fixtures for import_teamocil tests, for layout testing.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils teamocil_yaml_file = test_utils.get_workspace_file("import_teamocil/layouts.yaml") teamocil_yaml = test_utils.read_workspace_file("import_teamocil/layouts.yaml") diff --git a/tests/fixtures/import_teamocil/test1.py b/tests/fixtures/import_teamocil/test1.py index e1ad1c03791..38246268760 100644 --- a/tests/fixtures/import_teamocil/test1.py +++ b/tests/fixtures/import_teamocil/test1.py @@ -1,6 +1,6 @@ """Teamocil data fixtures for import_teamocil tests, 1st test.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils teamocil_yaml = test_utils.read_workspace_file("import_teamocil/test1.yaml") teamocil_conf = { diff --git a/tests/fixtures/import_teamocil/test2.py b/tests/fixtures/import_teamocil/test2.py index d6c259375d7..ad6986880f0 100644 --- a/tests/fixtures/import_teamocil/test2.py +++ b/tests/fixtures/import_teamocil/test2.py @@ -1,6 +1,6 @@ """Teamocil data fixtures for import_teamocil tests, 2nd test.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils teamocil_yaml = test_utils.read_workspace_file("import_teamocil/test2.yaml") teamocil_dict = { diff --git a/tests/fixtures/import_teamocil/test3.py b/tests/fixtures/import_teamocil/test3.py index 13f56021dec..5b2687c1c49 100644 --- a/tests/fixtures/import_teamocil/test3.py +++ b/tests/fixtures/import_teamocil/test3.py @@ -1,6 +1,6 @@ """Teamocil data fixtures for import_teamocil tests, 3rd test.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils teamocil_yaml = test_utils.read_workspace_file("import_teamocil/test3.yaml") @@ -31,7 +31,7 @@ "layout": "even-vertical", "start_directory": "~/Projects/foo-www", "shell_command_before": "rbenv local 2.0.0-p0", - "shell_command_after": ("echo " "'I am done initializing this pane.'"), + "shell_command_after": ("echo 'I am done initializing this pane.'"), "panes": [ {"shell_command": "git status"}, {"shell_command": "bundle exec rails server --port 40", "focus": True}, diff --git a/tests/fixtures/import_teamocil/test4.py b/tests/fixtures/import_teamocil/test4.py index 686d0f76473..b7883651b38 100644 --- a/tests/fixtures/import_teamocil/test4.py +++ b/tests/fixtures/import_teamocil/test4.py @@ -1,6 +1,6 @@ """Teamocil data fixtures for import_teamocil tests, 4th test.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils teamocil_yaml = test_utils.read_workspace_file("import_teamocil/test4.yaml") diff --git a/tests/fixtures/import_tmuxinator/test1.py b/tests/fixtures/import_tmuxinator/test1.py index 96de3899604..03fbc4196fd 100644 --- a/tests/fixtures/import_tmuxinator/test1.py +++ b/tests/fixtures/import_tmuxinator/test1.py @@ -1,6 +1,6 @@ """Tmuxinator data fixtures for import_tmuxinator tests, 1st dataset.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils tmuxinator_yaml = test_utils.read_workspace_file("import_tmuxinator/test1.yaml") tmuxinator_dict = { diff --git a/tests/fixtures/import_tmuxinator/test2.py b/tests/fixtures/import_tmuxinator/test2.py index 48e95d7ee4d..12fef7754af 100644 --- a/tests/fixtures/import_tmuxinator/test2.py +++ b/tests/fixtures/import_tmuxinator/test2.py @@ -1,6 +1,6 @@ """Tmuxinator data fixtures for import_tmuxinator tests, 2nd dataset.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils tmuxinator_yaml = test_utils.read_workspace_file("import_tmuxinator/test2.yaml") @@ -15,7 +15,7 @@ { "editor": { "pre": [ - 'echo "I get run in each pane, ' 'before each pane command!"', + 'echo "I get run in each pane, before each pane command!"', None, ], "layout": "main-vertical", diff --git a/tests/fixtures/import_tmuxinator/test3.py b/tests/fixtures/import_tmuxinator/test3.py index 39c75d0ce73..ed479c57b57 100644 --- a/tests/fixtures/import_tmuxinator/test3.py +++ b/tests/fixtures/import_tmuxinator/test3.py @@ -1,6 +1,6 @@ """Tmuxinator data fixtures for import_tmuxinator tests, 3rd dataset.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils tmuxinator_yaml = test_utils.read_workspace_file("import_tmuxinator/test3.yaml") @@ -15,7 +15,7 @@ { "editor": { "pre": [ - 'echo "I get run in each pane, ' 'before each pane command!"', + 'echo "I get run in each pane, before each pane command!"', None, ], "layout": "main-vertical", diff --git a/tests/fixtures/utils.py b/tests/fixtures/utils.py index 3752089264f..9e6b454bf6f 100644 --- a/tests/fixtures/utils.py +++ b/tests/fixtures/utils.py @@ -3,7 +3,7 @@ import pathlib import typing as t -from ..constants import FIXTURE_PATH +from tests.constants import FIXTURE_PATH def get_workspace_file( diff --git a/tests/fixtures/workspace/expand2.py b/tests/fixtures/workspace/expand2.py index c1a5d25d38d..3acdc3f3874 100644 --- a/tests/fixtures/workspace/expand2.py +++ b/tests/fixtures/workspace/expand2.py @@ -2,7 +2,7 @@ import pathlib -from .. import utils as test_utils +from tests.fixtures import utils as test_utils def unexpanded_yaml() -> str: diff --git a/tests/fixtures/workspace/shell_command_before_session.py b/tests/fixtures/workspace/shell_command_before_session.py index 9dccd9f930d..f3639ded0ce 100644 --- a/tests/fixtures/workspace/shell_command_before_session.py +++ b/tests/fixtures/workspace/shell_command_before_session.py @@ -1,6 +1,6 @@ """Tests shell_command_before configuration.""" -from .. import utils as test_utils +from tests.fixtures import utils as test_utils before = test_utils.read_workspace_file("workspace/shell_command_before_session.yaml") expected = test_utils.read_workspace_file( diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 8bd3fc77d51..feee07d3755 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -25,7 +25,6 @@ @pytest.fixture(autouse=True) def autopatch_sitedir(monkeypatch_plugin_test_packages: None) -> None: """Fixture automatically used that patches sitedir.""" - pass def test_all_pass() -> None: diff --git a/tests/test_util.py b/tests/test_util.py index 8884734813b..04e29406887 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -34,7 +34,7 @@ def test_return_stdout_if_ok(capsys: pytest.CaptureFixture[str]) -> None: script_file = FIXTURE_PATH / "script_complete.sh" run_before_script(script_file) - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert "hello" in out diff --git a/tests/workspace/conftest.py b/tests/workspace/conftest.py index 11af35f89f4..b855f312c9f 100644 --- a/tests/workspace/conftest.py +++ b/tests/workspace/conftest.py @@ -4,17 +4,17 @@ import pytest -from ..fixtures.structures import WorkspaceTestData +from tests.fixtures.structures import WorkspaceTestData -@pytest.fixture +@pytest.fixture() def config_fixture() -> WorkspaceTestData: """Deferred import of tmuxp.tests.fixtures.*. pytest setup (conftest.py) patches os.environ["HOME"], delay execution of os.path.expanduser until here. """ - from ..fixtures import workspace as test_workspace_data + from tests.fixtures import workspace as test_workspace_data return WorkspaceTestData( **{ diff --git a/tests/workspace/test_builder.py b/tests/workspace/test_builder.py index 875861f0f9b..155c4d733f3 100644 --- a/tests/workspace/test_builder.py +++ b/tests/workspace/test_builder.py @@ -18,15 +18,14 @@ from libtmux.test import retry_until, temp_session from libtmux.window import Window +from tests.constants import EXAMPLE_PATH, FIXTURE_PATH +from tests.fixtures import utils as test_utils from tmuxp import exc from tmuxp._internal.config_reader import ConfigReader from tmuxp.cli.load import load_plugins from tmuxp.workspace import loader from tmuxp.workspace.builder import WorkspaceBuilder -from ..constants import EXAMPLE_PATH, FIXTURE_PATH -from ..fixtures import utils as test_utils - if t.TYPE_CHECKING: class AssertCallbackProtocol(t.Protocol): @@ -111,7 +110,7 @@ def test_focus_pane_index(session: Session) -> None: if pane is not None and pane.index is not None ] - pane_indexes_should_be = [pane_base_index + x for x in range(0, 3)] + pane_indexes_should_be = [pane_base_index + x for x in range(3)] assert pane_indexes_should_be == pane_base_indexes w = session.active_window @@ -513,10 +512,10 @@ def check_window_name_mismatch() -> bool: def check_window_name_match() -> bool: assert w.show_window_option("automatic-rename") == "on" - return ( - w.name == pathlib.Path(os.getenv("SHELL", "bash")).name - or w.name == portable_command - ) + return w.name in { + pathlib.Path(os.getenv("SHELL", "bash")).name, + portable_command, + } assert retry_until( check_window_name_match, @@ -1097,9 +1096,9 @@ def test_find_current_active_pane( @pytest.mark.parametrize( - "yaml,output,should_see", + ("yaml", "output", "should_see"), [ - [ + ( textwrap.dedent( """ session_name: Should not execute @@ -1111,8 +1110,8 @@ def test_find_current_active_pane( ), "___4___", False, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1125,8 +1124,8 @@ def test_find_current_active_pane( ), "___4___", False, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should execute @@ -1137,8 +1136,8 @@ def test_find_current_active_pane( ), "___4___", True, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should execute @@ -1150,8 +1149,8 @@ def test_find_current_active_pane( ), "___4___", True, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1164,8 +1163,8 @@ def test_find_current_active_pane( ), "___4___", False, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1178,8 +1177,8 @@ def test_find_current_active_pane( ), "___4___", False, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should execute @@ -1190,8 +1189,8 @@ def test_find_current_active_pane( ), "___4___", True, - ], - [ + ), + ( textwrap.dedent( """ session_name: Should execute @@ -1204,7 +1203,7 @@ def test_find_current_active_pane( ), "___4___", True, - ], + ), ], ids=[ "pane_enter_false_shortform", @@ -1244,8 +1243,7 @@ def fn() -> bool: if should_see: return output in captured_pane - else: - return output not in captured_pane + return output not in captured_pane assert retry_until( fn, @@ -1254,9 +1252,9 @@ def fn() -> bool: @pytest.mark.parametrize( - "yaml,sleep,output", + ("yaml", "sleep", "output"), [ - [ + ( textwrap.dedent( """ session_name: Should not execute @@ -1271,8 +1269,8 @@ def fn() -> bool: ), 0.5, "___4___", - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1287,8 +1285,8 @@ def fn() -> bool: ), 1.25, "___4___", - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1301,8 +1299,8 @@ def fn() -> bool: ), 0.5, "___4___", - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1315,8 +1313,8 @@ def fn() -> bool: ), 1, "___4___", - ], - [ + ), + ( textwrap.dedent( """ session_name: Should not execute @@ -1330,7 +1328,7 @@ def fn() -> bool: ), 0.5, "___4___", - ], + ), ], ids=[ "command_level_sleep_shortform", diff --git a/tests/workspace/test_config.py b/tests/workspace/test_config.py index 222a85d7144..cc417a89f5b 100644 --- a/tests/workspace/test_config.py +++ b/tests/workspace/test_config.py @@ -5,14 +5,13 @@ import pytest +from tests.constants import EXAMPLE_PATH from tmuxp import exc from tmuxp._internal.config_reader import ConfigReader from tmuxp.workspace import loader, validation -from ..constants import EXAMPLE_PATH - if t.TYPE_CHECKING: - from ..fixtures.structures import WorkspaceTestData + from tests.fixtures.structures import WorkspaceTestData def load_workspace(path: t.Union[str, pathlib.Path]) -> t.Dict[str, t.Any]: diff --git a/tests/workspace/test_finder.py b/tests/workspace/test_finder.py index 0bf3de9ae6f..a7a8ffdc638 100644 --- a/tests/workspace/test_finder.py +++ b/tests/workspace/test_finder.py @@ -62,7 +62,7 @@ def test_get_configs_cwd( @pytest.mark.parametrize( - "path,expect", + ("path", "expect"), [ (".", False), ("./", False), @@ -104,7 +104,7 @@ def test_tmuxp_configdir_xdg_config_dir( assert get_workspace_dir() == str(tmux_dir) -@pytest.fixture +@pytest.fixture() def homedir(tmp_path: pathlib.Path) -> pathlib.Path: """Fixture to ensure and return a home directory.""" home = tmp_path / "home" @@ -112,7 +112,7 @@ def homedir(tmp_path: pathlib.Path) -> pathlib.Path: return home -@pytest.fixture +@pytest.fixture() def configdir(homedir: pathlib.Path) -> pathlib.Path: """Fixture to ensure user directory for tmuxp and return it, via homedir fixture.""" conf = homedir / ".tmuxp" @@ -120,7 +120,7 @@ def configdir(homedir: pathlib.Path) -> pathlib.Path: return conf -@pytest.fixture +@pytest.fixture() def projectdir(homedir: pathlib.Path) -> pathlib.Path: """Fixture to ensure and return an example project dir.""" proj = homedir / "work" / "project" diff --git a/tests/workspace/test_freezer.py b/tests/workspace/test_freezer.py index 22088003764..c762e2212e2 100644 --- a/tests/workspace/test_freezer.py +++ b/tests/workspace/test_freezer.py @@ -6,14 +6,13 @@ from libtmux.session import Session +from tests.fixtures import utils as test_utils from tmuxp._internal.config_reader import ConfigReader from tmuxp.workspace import freezer, validation from tmuxp.workspace.builder import WorkspaceBuilder -from ..fixtures import utils as test_utils - if typing.TYPE_CHECKING: - from ..fixtures.structures import WorkspaceTestData + from tests.fixtures.structures import WorkspaceTestData def test_freeze_config(session: Session) -> None: diff --git a/tests/workspace/test_import_teamocil.py b/tests/workspace/test_import_teamocil.py index 3d9dc830d07..8ae913c61ec 100644 --- a/tests/workspace/test_import_teamocil.py +++ b/tests/workspace/test_import_teamocil.py @@ -4,14 +4,13 @@ import pytest +from tests.fixtures import import_teamocil as fixtures from tmuxp._internal import config_reader from tmuxp.workspace import importers, validation -from ..fixtures import import_teamocil as fixtures - @pytest.mark.parametrize( - "teamocil_yaml,teamocil_dict,tmuxp_dict", + ("teamocil_yaml", "teamocil_dict", "tmuxp_dict"), [ ( fixtures.test1.teamocil_yaml, @@ -73,7 +72,7 @@ def multisession_config() -> ( @pytest.mark.parametrize( - "session_name,expected", + ("session_name", "expected"), [ ("two-windows", fixtures.layouts.two_windows), ("two-windows-with-filters", fixtures.layouts.two_windows_with_filters), diff --git a/tests/workspace/test_import_tmuxinator.py b/tests/workspace/test_import_tmuxinator.py index 81703b28d29..d5dfe3ba2ec 100644 --- a/tests/workspace/test_import_tmuxinator.py +++ b/tests/workspace/test_import_tmuxinator.py @@ -4,14 +4,13 @@ import pytest +from tests.fixtures import import_tmuxinator as fixtures from tmuxp._internal.config_reader import ConfigReader from tmuxp.workspace import importers, validation -from ..fixtures import import_tmuxinator as fixtures - @pytest.mark.parametrize( - "tmuxinator_yaml,tmuxinator_dict,tmuxp_dict", + ("tmuxinator_yaml", "tmuxinator_dict", "tmuxp_dict"), [ ( fixtures.test1.tmuxinator_yaml,