Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Jul 10, 2024
1 parent 2cd7e39 commit 79e4618
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 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

0 comments on commit 79e4618

Please sign in to comment.