Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code quality improvements #390

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading