Skip to content

Commit

Permalink
chore: Update pyproject.toml (#194)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
cidrblock and pre-commit-ci[bot] authored May 31, 2024
1 parent e542f65 commit 7a27513
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 52 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/ansible_dev_environment/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions src/ansible_dev_environment/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/ansible_dev_environment/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 5 additions & 16 deletions src/ansible_dev_environment/subcommands/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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."
Expand All @@ -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 = (
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions src/ansible_dev_environment/subcommands/lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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())
Expand Down
5 changes: 1 addition & 4 deletions src/ansible_dev_environment/subcommands/uninstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
12 changes: 3 additions & 9 deletions src/ansible_dev_environment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a27513

Please sign in to comment.