From 7a27513c6e28f53d8664981fd40197fa2759c2b7 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 31 May 2024 16:15:36 -0700 Subject: [PATCH] chore: Update pyproject.toml (#194) * Update pyproject.toml * chore: auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- pyproject.toml | 3 +++ src/ansible_dev_environment/cli.py | 9 ++------ src/ansible_dev_environment/collection.py | 4 +--- src/ansible_dev_environment/output.py | 4 +--- .../subcommands/installer.py | 21 +++++-------------- .../subcommands/lister.py | 8 ++----- .../subcommands/uninstaller.py | 5 +---- src/ansible_dev_environment/utils.py | 12 +++-------- tests/unit/test_utils.py | 5 +---- 9 files changed, 19 insertions(+), 52 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dd5728b..8c2759c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,9 @@ documentation = "https://ansible.readthedocs.io/projects/dev-environment/" homepage = "https://github.com/ansible/ansible-dev-environment" repository = "https://github.com/ansible/ansible-dev-environment" +[tool.black] +line-length = 100 + [tool.coverage.report] exclude_lines = ["if TYPE_CHECKING:", "pragma: no cover"] fail_under = 72 diff --git a/src/ansible_dev_environment/cli.py b/src/ansible_dev_environment/cli.py index bf1cacf..0c5eeb2 100644 --- a/src/ansible_dev_environment/cli.py +++ b/src/ansible_dev_environment/cli.py @@ -37,9 +37,7 @@ def parse_args(self: Cli) -> None: if hasattr(self.args, "requirement") and self.args.requirement: self.args.requirement = Path(self.args.requirement).expanduser().resolve() if self.args.cpi: - self.args.requirement = ( - Path(".config/source-requirements.yml").expanduser().resolve() - ) + self.args.requirement = Path(".config/source-requirements.yml").expanduser().resolve() def init_output(self: Cli) -> None: """Initialize the output object.""" @@ -137,10 +135,7 @@ def ensure_isolated(self: Cli) -> None: errored = True if errored: - err = ( - "The development environment is not isolated," - " please resolve the above errors." - ) + err = "The development environment is not isolated, please resolve the above errors." self.output.critical(err) diff --git a/src/ansible_dev_environment/collection.py b/src/ansible_dev_environment/collection.py index 9a23233..22cc43e 100644 --- a/src/ansible_dev_environment/collection.py +++ b/src/ansible_dev_environment/collection.py @@ -128,9 +128,7 @@ def parse_collection_request( # noqa: PLR0915 ) matched = non_local_re.match(string) if not matched: - msg = ( - "Specify a valid collection name (ns.n) with an optional version specifier" - ) + msg = "Specify a valid collection name (ns.n) with an optional version specifier" output.hint(msg) msg = f"Failed to parse collection request: {string}" output.critical(msg) diff --git a/src/ansible_dev_environment/output.py b/src/ansible_dev_environment/output.py index 577f14f..43a901b 100644 --- a/src/ansible_dev_environment/output.py +++ b/src/ansible_dev_environment/output.py @@ -132,9 +132,7 @@ def __str__(self: Level) -> str: Returns: The exit message prefix as a string """ - return ( - f"{' ' * (self._longest_name() - len(self.name))}{self.name.capitalize()}: " - ) + return f"{' ' * (self._longest_name() - len(self.name))}{self.name.capitalize()}: " @dataclass diff --git a/src/ansible_dev_environment/subcommands/installer.py b/src/ansible_dev_environment/subcommands/installer.py index 0bb9677..c955102 100644 --- a/src/ansible_dev_environment/subcommands/installer.py +++ b/src/ansible_dev_environment/subcommands/installer.py @@ -44,10 +44,7 @@ def __init__(self: Installer, config: Config, output: Output) -> None: def run(self: Installer) -> None: """Run the installer.""" - if ( - self._config.args.collection_specifier - and "," in self._config.args.collection_specifier - ): + if self._config.args.collection_specifier and "," in self._config.args.collection_specifier: err = "Multiple optional dependencies are not supported at this time." self._output.critical(err) @@ -67,16 +64,12 @@ def run(self: Installer) -> None: ) for entry in self._config.args.collection_specifier ] - local_collections = [ - collection for collection in collections if collection.local - ] + local_collections = [collection for collection in collections if collection.local] for local_collection in local_collections: self._install_local_collection(collection=local_collection) if self._config.args.editable: self._swap_editable_collection(collection=local_collection) - distant_collections = [ - collection for collection in collections if not collection.local - ] + distant_collections = [collection for collection in collections if not collection.local] if distant_collections: if self._config.args.editable: msg = "Editable installs are only supported for local collections." @@ -87,9 +80,7 @@ def run(self: Installer) -> None: self._pip_install() Checker(config=self._config, output=self._output).system_deps() - if self._config.args.venv and ( - self._config.interpreter != self._config.venv_interpreter - ): + if self._config.args.venv and (self._config.interpreter != self._config.venv_interpreter): msg = "A virtual environment was specified but has not been activated." self._output.note(msg) msg = ( @@ -522,9 +513,7 @@ def _pip_install(self: Installer) -> None: f" -r {self._config.discovered_python_reqs}" ) - msg = ( - f"Installing python requirements from {self._config.discovered_python_reqs}" - ) + msg = f"Installing python requirements from {self._config.discovered_python_reqs}" self._output.debug(msg) work = "Installing python requirements" try: diff --git a/src/ansible_dev_environment/subcommands/lister.py b/src/ansible_dev_environment/subcommands/lister.py index 1ad5e30..b8b6aff 100644 --- a/src/ansible_dev_environment/subcommands/lister.py +++ b/src/ansible_dev_environment/subcommands/lister.py @@ -46,9 +46,7 @@ def run(self: Lister) -> None: f" {'Editable project location': <{column3_width}}", ) print( # noqa: T201 - f"{'-' * (column1_width)}" - f" {'-' * (column2_width)}" - f" {'-' * (column3_width)}", + f"{'-' * (column1_width)} {'-' * (column2_width)} {'-' * (column3_width)}", ) for fqcn, collection in collections.items(): @@ -71,9 +69,7 @@ def run(self: Lister) -> None: continue collection_path = ( - self._config.site_pkg_collections_path - / collection_namespace - / collection_name + self._config.site_pkg_collections_path / collection_namespace / collection_name ) if collection_path.is_symlink(): editable_location = str(collection_path.resolve()) diff --git a/src/ansible_dev_environment/subcommands/uninstaller.py b/src/ansible_dev_environment/subcommands/uninstaller.py index 0da80ff..16176fe 100644 --- a/src/ansible_dev_environment/subcommands/uninstaller.py +++ b/src/ansible_dev_environment/subcommands/uninstaller.py @@ -76,10 +76,7 @@ def _remove_collection(self: UnInstaller) -> None: msg = f"Removed {self._collection.name}" self._output.note(msg) else: - err = ( - f"Failed to find {self._collection.name}:" - f" {self._collection.site_pkg_path}" - ) + err = f"Failed to find {self._collection.name}: {self._collection.site_pkg_path}" self._output.warning(err) for entry in self._config.site_pkg_collections_path.iterdir(): diff --git a/src/ansible_dev_environment/utils.py b/src/ansible_dev_environment/utils.py index cbd35e5..fbf4c3a 100644 --- a/src/ansible_dev_environment/utils.py +++ b/src/ansible_dev_environment/utils.py @@ -191,9 +191,7 @@ def sort_dict(item: dict[str, Any]) -> dict[str, Any]: Returns: The sorted dictionary. """ - return { - k: sort_dict(v) if isinstance(v, dict) else v for k, v in sorted(item.items()) - } + return {k: sort_dict(v) if isinstance(v, dict) else v for k, v in sorted(item.items())} def collect_manifests( # noqa: C901 @@ -220,9 +218,7 @@ def collect_manifests( # noqa: C901 manifest = name_dir / "MANIFEST.json" if not manifest.exists(): manifest = ( - venv_cache_dir - / f"{namespace_dir.name}.{name_dir.name}" - / "MANIFEST.json" + venv_cache_dir / f"{namespace_dir.name}.{name_dir.name}" / "MANIFEST.json" ) if not manifest.exists(): msg = f"Manifest not found for {namespace_dir.name}.{name_dir.name}" @@ -368,9 +364,7 @@ def collections_meta(config: Config) -> dict[str, dict[str, Any]]: elif (name_dir / "galaxy.yml").exists(): file = name_dir / "galaxy.yml" - editable_location = ( - str(name_dir.resolve()) if name_dir.is_symlink() else "" - ) + editable_location = str(name_dir.resolve()) if name_dir.is_symlink() else "" if file: with file.open() as info_file: diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index be8225f..bf171b2 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -113,7 +113,4 @@ def test_parse_collection_request(scenario: tuple[str, Collection | None]) -> No with pytest.raises(SystemExit): parse_collection_request(string=string, config=config, output=output) else: - assert ( - parse_collection_request(string=string, config=config, output=output) - == spec - ) + assert parse_collection_request(string=string, config=config, output=output) == spec