Skip to content

Commit

Permalink
Enable flake8-builtins plugin for ruff (#2333)
Browse files Browse the repository at this point in the history
  • Loading branch information
cutwater authored Oct 24, 2024
1 parent 4de5525 commit b530dd2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion galaxy_ng/app/management/commands/dump-auth-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def post_config_ldap(self):

return post_config

def format_config_data(self, type, keys, prefix):
def format_config_data(self, type, keys, prefix): # noqa: A002
config = {
"type": f"galaxy.authentication.authenticator_plugins.{type}",
"enabled": self.is_enabled(keys),
Expand Down
8 changes: 4 additions & 4 deletions galaxy_ng/tests/integration/api/test_artifact_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def test_download_artifact(ansible_config, galaxy_client):
hub_4_5 = is_hub_4_5(ansible_config)
set_certification(ansible_config(), gc, artifact, hub_4_5=hub_4_5)

with tempfile.TemporaryDirectory() as dir:
with tempfile.TemporaryDirectory() as dir_:
filename = f"{namespace}-{name}-{version}.tar.gz"
tarball_path = f"{dir}/{filename}"
tarball_path = f"{dir_}/{filename}"
url = (f"{gc.galaxy_root}v3/plugin/ansible/content/"
f"published/collections/artifacts/{filename}")

Expand Down Expand Up @@ -94,9 +94,9 @@ def test_download_artifact_validated(ansible_config, galaxy_client):
assert resp["state"] == "completed"
set_certification(ansible_config(), gc, artifact, level="validated")

with tempfile.TemporaryDirectory() as dir:
with tempfile.TemporaryDirectory() as dir_:
filename = f"{artifact.namespace}-{artifact.name}-{artifact.version}.tar.gz"
tarball_path = f"{dir}/{filename}"
tarball_path = f"{dir_}/{filename}"
url = (f"{gc.galaxy_root}v3/plugin/ansible/content/"
f"validated/collections/artifacts/{filename}")

Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/tests/integration/api/test_artifact_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class ErrorTestMode:
"""Represents a test scenario for publishing a collection."""

def __init__(self, name, file, status, resp, no_filename=False, hash=True):
def __init__(self, name, file, status, resp, no_filename=False, hash=True): # noqa: A002
"""Configure the test scenario.
:param name: Name for use in the test ID.
Expand Down
4 changes: 2 additions & 2 deletions galaxy_ng/tests/integration/api/test_galaxy_stage_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ def test_social_download_artifact(gh_user_1, generate_test_artifact):
resp = wait_for_task(gh_user_1, resp)
assert resp["state"] == "completed"

with tempfile.TemporaryDirectory() as dir:
with tempfile.TemporaryDirectory() as dir_:
filename = f"{expected_ns}-{generate_test_artifact.name}-" \
f"{generate_test_artifact.version}.tar.gz"
tarball_path = f"{dir}/{filename}"
tarball_path = f"{dir_}/{filename}"
url = f"{gh_user_1.galaxy_root}v3/plugin/" \
f"ansible/content/published/collections/artifacts/{filename}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def _upload_test_common(config, client, artifact, base_path, dest_base_path=None
assert collection_resp["name"] == artifact.name

# test download
with tempfile.TemporaryDirectory() as dir:
with tempfile.TemporaryDirectory() as dir_:
if gc:
api_root = gc.galaxy_root
else:
api_root = config["url"]
filename = f"{artifact.namespace}-{artifact.name}-{artifact.version}.tar.gz"
tarball_path = f"{dir}/{filename}"
tarball_path = f"{dir_}/{filename}"
url = (
f"{api_root}v3/plugin/ansible/content/"
f"{dest_base_path}/collections/artifacts/{filename}"
Expand Down
8 changes: 7 additions & 1 deletion galaxy_ng/tests/integration/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,13 @@ def build_collection(


def upload_artifact(
config, client, artifact, hash=True, no_filename=False, no_file=False, use_distribution=False
config,
client,
artifact,
hash=True, # noqa: A002
no_filename=False,
no_file=False,
use_distribution=False
):
"""
Publishes a collection to a Galaxy server and returns the import task URI.
Expand Down
22 changes: 11 additions & 11 deletions galaxy_ng/tests/integration/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ def random_name(prefix: str, *, length: int = 8, sep: str = '-'):

def iterate_all(api_client, url, gc=None):
"""Iterate through all of the items on every page in a paginated list view."""
next = url
next_ = url
key = "data"
while next is not None:
while next_ is not None:
if gc:
r = gc.get(next)
r = gc.get(next_)
else:
r = api_client(next)
r = api_client(next_)
# pulp uses "results"
if "data" not in r:
key = "results"
yield from r[key]
if "next" in r:
next = r["next"]
next_ = r["next"]
else:
next = r["links"]["next"]
next_ = r["links"]["next"]


def generate_random_artifact_version():
Expand All @@ -59,15 +59,15 @@ def gen_string(size=10, chars=string.ascii_lowercase):

def iterate_all_gk(gc_admin, url):
"""Iterate through all of the items on every page in a paginated list view."""
next = url
next_ = url
key = "data"
while next is not None:
r = gc_admin.get(next)
while next_ is not None:
r = gc_admin.get(next_)
# pulp uses "results"
if "data" not in r:
key = "results"
yield from r[key]
if "next" in r:
next = r["next"]
next_ = r["next"]
else:
next = r["links"]["next"]
next_ = r["links"]["next"]
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ select = [
"E",
# pycodestyle warnings
"W",
# flake8-builtins
"A",
# flake8-bugbear
"B",
# flake8-comprehensions
Expand Down Expand Up @@ -153,3 +155,6 @@ extend-ignore = [
# Ignore "E501 Line too long" in migrations, since most of the warnings
# are due to autogenerated code.
"galaxy_ng/app/migrations/*" = ["E501"]

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["id"]

0 comments on commit b530dd2

Please sign in to comment.