Skip to content

Commit

Permalink
Minor code quality improvements (#390)
Browse files Browse the repository at this point in the history
* Improve code quality

* ruff
  • Loading branch information
cidrblock authored Jul 10, 2024
1 parent 2cd7e39 commit 557e744
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exclude: |
)$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.7"
rev: "v0.5.0"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
8 changes: 4 additions & 4 deletions src/ansible_compat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def ansible_version(version: str = "") -> Version:
if version:
return Version(version)

proc = subprocess.run(
["ansible", "--version"], # noqa: S603
proc = subprocess.run( # noqa: S603
["ansible", "--version"],
text=True,
check=False,
capture_output=True,
Expand Down Expand Up @@ -413,8 +413,8 @@ def __init__(
env = os.environ.copy()
# Avoid possible ANSI garbage
env["ANSIBLE_FORCE_COLOR"] = "0"
config_dump = subprocess.check_output(
["ansible-config", "dump"], # noqa: S603
config_dump = subprocess.check_output( # noqa: S603
["ansible-config", "dump"],
universal_newlines=True,
env=env,
)
Expand Down
9 changes: 2 additions & 7 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ def version_in_range(
"""
if lower and self.version < Version(lower):
return False
if upper and self.version >= Version(upper):
return False
return True
return not (upper and self.version >= Version(upper))

def has_playbook(self, playbook: str, *, basedir: Path | None = None) -> bool:
"""Return true if ansible can load a given playbook.
Expand Down Expand Up @@ -701,10 +699,7 @@ def prepare_environment( # noqa: C901
galaxy_path.parent,
destination=destination,
)
elif (
Path().resolve().parent.name == "roles"
and Path("../../galaxy.yml").exists()
):
elif Path.cwd().parent.name == "roles" and Path("../../galaxy.yml").exists():
# molecule scenario located within roles/<role-name>/molecule inside
# a collection
self.install_collection_from_disk(
Expand Down
4 changes: 2 additions & 2 deletions test/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ def test__update_env(

def test_require_collection_wrong_version(runtime: Runtime) -> None:
"""Tests behaviour of require_collection."""
subprocess.check_output(
[ # noqa: S603
subprocess.check_output( # noqa: S603
[
"ansible-galaxy",
"collection",
"install",
Expand Down

0 comments on commit 557e744

Please sign in to comment.