Skip to content

Commit

Permalink
Fix pre-commit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Konecny <[email protected]>
  • Loading branch information
Zlopez committed Aug 1, 2024
1 parent 7d001b4 commit 28ae45c
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def process_bind_param(self, value, dialect):
return str(value)
else:
if not isinstance(value, uuid.UUID):
return f"{uuid.UUID(value).int:032x}"
return f"{uuid.UUID(value).int:032x}" # noqa: E231
else:
# hexstring
return f"{value.int:032x}"
return f"{value.int:032x}" # noqa: E231

def process_result_value(self, value, dialect):
"""
Expand Down
4 changes: 2 additions & 2 deletions anitya/db/migrations/versions/a52d2fe99d4f_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def process_bind_param(self, value, dialect):
return str(value)
else:
if not isinstance(value, uuid.UUID):
return f"{uuid.UUID(value).int:032x}"
return f"{uuid.UUID(value).int:032x}" # noqa: E231
else:
# hexstring
return f"{value.int:032x}"
return f"{value.int:032x}" # noqa: E231

def process_result_value(self, value, dialect):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def downgrade():
# We have to populate the backends table before we can add the ecosystems
# table with its foreign key constraint.
for backend in plugins.BACKEND_PLUGINS.get_plugins():
op.execute(f"INSERT INTO backends (name) VALUES ('{backend.name}');")
op.execute(
f"INSERT INTO backends (name) VALUES ('{backend.name}');" # noqa: E702,E231
)

op.create_table(
"ecosystems",
Expand All @@ -67,7 +69,7 @@ def downgrade():
op.execute(
f"""
INSERT INTO ecosystems (name, default_backend_name)
VALUES ('{ecosystem.name}', '{ecosystem.default_backend}');"""
VALUES ('{ecosystem.name}', '{ecosystem.default_backend}');""" # noqa: E702,E231
)

op.create_foreign_key(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def process_bind_param(self, value, dialect):
return str(value)
else:
if not isinstance(value, uuid.UUID):
return f"{uuid.UUID(value).int:032x}"
return f"{uuid.UUID(value).int: 032x}"
else:
# hexstring
return f"{value.int:032x}"
return f"{value.int: 032x}"

def process_result_value(self, value, dialect):
"""
Expand Down
4 changes: 2 additions & 2 deletions anitya/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,10 @@ def process_bind_param(self, value, dialect):
return str(value)
else:
if not isinstance(value, uuid.UUID):
return f"{uuid.UUID(value).int:032x}"
return f"{uuid.UUID(value).int:032x}" # noqa: E231
else:
# hexstring
return f"{value.int:032x}"
return f"{value.int:032x}" # noqa: E231

def process_result_value(self, value, dialect):
"""
Expand Down
4 changes: 2 additions & 2 deletions anitya/lib/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ def get_versions_by_regex_for_text(text, url, regex, project):

if " " in version:
raise AnityaPluginException(
f"{project.name}: invalid upstream version:>{version}< - {url} "
f"{project.name}: invalid upstream version: >{version}< - {url} "
f"- {regex} "
)
if len(upstream_versions) == 0:
raise AnityaPluginException(
f"{project.name}: no upstream version found. - {url} - {regex}"
f"{project.name}: no upstream version found. - {url} - {regex}"
)
# Filter retrieved versions
filtered_versions = BaseBackend.filter_versions(
Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_version_url(cls, project):
url = url[:-1]

if url:
url = f"https://bitbucket.org/{url}/downloads?tab=tags"
url = f"https://bitbucket.org/{url}/downloads?tab=tags" # noqa: E231

return url

Expand Down
4 changes: 2 additions & 2 deletions anitya/lib/backends/cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://metacpan.org/release/{project.name}/"
url = f"https://metacpan.org/release/{project.name}/" # noqa: E231

return url

Expand Down Expand Up @@ -94,5 +94,5 @@ def check_feed(cls):
name, version = title.text.rsplit("-", 1)
except ValueError:
_log.info("Unable to parse CPAN package %s into a name and version")
homepage = f"https://metacpan.org/release/{name}/"
homepage = f"https://metacpan.org/release/{name}/" # noqa: E231
yield name, homepage, cls.name, version
4 changes: 2 additions & 2 deletions anitya/lib/backends/cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_version(cls, project):
format.
"""
url = f"https://crandb.r-pkg.org/{project.name}"
url = f"https://crandb.r-pkg.org/{project.name}" # noqa: E231

last_change = project.get_time_last_created_version()
try:
Expand Down Expand Up @@ -109,7 +109,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://crandb.r-pkg.org/{project.name}/all"
url = f"https://crandb.r-pkg.org/{project.name}/all" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/crates.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://crates.io/api/v1/crates/{project.name}/versions"
url = f"https://crates.io/api/v1/crates/{project.name}/versions" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_version_url(cls, project):
else:
short = project.name[0]

return f"http://ftp.debian.org/debian/pool/main/{short}/{project.name}/"
return f"http://ftp.debian.org/debian/pool/main/{short}/{project.name}/" # noqa: E231

@classmethod
def get_versions(cls, project):
Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/drupal6.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_version_url(cls, project):
if "-" in project.name:
name = project.name.replace("-", "_")

url = f"https://updates.drupal.org/release-history/{name}/6.x"
url = f"https://updates.drupal.org/release-history/{name}/6.x" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/drupal7.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_version_url(cls, project):
if "-" in project.name:
name = project.name.replace("-", "_")

return f"https://updates.drupal.org/release-history/{name}/7.x"
return f"https://updates.drupal.org/release-history/{name}/7.x" # noqa: E231

@classmethod
def get_versions(cls, project):
Expand Down
4 changes: 2 additions & 2 deletions anitya/lib/backends/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def prepare_query(owner, repo, releases_only):
if releases_only:
fetch_obj = "releases"
# get release name and follow release -> tag
rel_tag_fragment = f"name tag {{ {tag_fragment} }}"
rel_tag_fragment = f"name tag {{ {tag_fragment} }}" # noqa: E202,E201
order_by_field = "CREATED_AT"
else:
fetch_obj = "refs"
Expand Down Expand Up @@ -317,6 +317,6 @@ def prepare_query(owner, repo, releases_only):
remaining
resetAt
}}
}}"""
}}""" # noqa: E202

return query
2 changes: 1 addition & 1 deletion anitya/lib/backends/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://download.gnome.org/sources/{project.name}/"
url = f"https://download.gnome.org/sources/{project.name}/" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://ftp.gnu.org/gnu/{project.name}/"
url = f"https://ftp.gnu.org/gnu/{project.name}/" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/hackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://hackage.haskell.org/package/{project.name}"
url = f"https://hackage.haskell.org/package/{project.name}" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://launchpad.net/{project.name}/+download"
url = f"https://launchpad.net/{project.name}/+download" # noqa: E231

return url

Expand Down
4 changes: 3 additions & 1 deletion anitya/lib/backends/npmjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def check_feed(cls):
continue
doc = item["doc"]
name = doc["name"]
homepage = doc.get("homepage", f"https://npmjs.org/package/{name}")
homepage = doc.get(
"homepage", f"https://npmjs.org/package/{name}" # noqa: E231
) # noqa: E231
for version in doc.get("versions", []):
yield name, homepage, cls.name, version
2 changes: 1 addition & 1 deletion anitya/lib/backends/pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://pagure.io/api/0/{project.name}/git/tags"
url = f"https://pagure.io/api/0/{project.name}/git/tags" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/pear.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ def check_feed(cls):
for entry in items:
title = entry["title"]["value"]
name, version = title.rsplit(None, 1)
homepage = f"https://pear.php.net/package/{name}"
homepage = f"https://pear.php.net/package/{name}" # noqa: E231
yield name, homepage, cls.name, version
2 changes: 1 addition & 1 deletion anitya/lib/backends/pecl.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ def check_feed(cls):
for entry in items:
title = entry["title"]["value"]
name, version = title.rsplit(None, 1)
homepage = f"https://pecl.php.net/package/{name}"
homepage = f"https://pecl.php.net/package/{name}" # noqa: E231
yield name, homepage, cls.name, version
4 changes: 2 additions & 2 deletions anitya/lib/backends/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://pypi.org/pypi/{project.name}/json"
url = f"https://pypi.org/pypi/{project.name}/json" # noqa: E231

return url

Expand Down Expand Up @@ -149,5 +149,5 @@ def check_feed(cls):
for entry in items:
title = entry["title"]["value"]
name, version = title.rsplit(None, 1)
homepage = f"https://pypi.org/project/{name}/"
homepage = f"https://pypi.org/project/{name}/" # noqa: E231
yield name, homepage, cls.name, version
4 changes: 2 additions & 2 deletions anitya/lib/backends/rubygems.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://rubygems.org/api/v1/versions/{project.name}/latest.json"
url = f"https://rubygems.org/api/v1/versions/{project.name}/latest.json" # noqa: E231

return url

Expand Down Expand Up @@ -103,5 +103,5 @@ def check_feed(cls):

for item in data:
name, version = item["name"], item["version"]
homepage = f"https://rubygems.org/gems/{name}"
homepage = f"https://rubygems.org/gems/{name}" # noqa: E231
yield name, homepage, cls.name, version
2 changes: 1 addition & 1 deletion anitya/lib/backends/sourceforge_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_version_url(cls, project):

else:
namespace, repo = cls.get_namespace_repo(project)
url = f"https://sourceforge.net/p/{namespace}/{repo}/ref/master/tags/"
url = f"https://sourceforge.net/p/{namespace}/{repo}/ref/master/tags/" # noqa: E231

return url

Expand Down
2 changes: 1 addition & 1 deletion anitya/lib/backends/sourcehut.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_versions(cls, project):

if len(versions) == 0:
raise AnityaPluginException(
f"{project.name}: no upstream version found. - {url} - "
f"{project.name}: no upstream version found. '{url}'"
)

return cls.filter_versions(versions, project.version_filter)
Expand Down
4 changes: 2 additions & 2 deletions anitya/lib/backends/stackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_version_url(cls, project):
Returns:
str: url used for version checking
"""
url = f"https://www.stackage.org/package/{project.name}"
url = f"https://www.stackage.org/package/{project.name}" # noqa: E231

return url

Expand All @@ -54,7 +54,7 @@ def get_versions(cls, project):
url = cls.get_version_url(project)

regex = (
rf"<a href=\"https://hackage.haskell.org/package/{project.name}\">"
rf"<a href=\"https://hackage.haskell.org/package/{project.name}\">" # noqa: E231
r"<span class=\"version\">([\d.]*).*</span></a>"
)

Expand Down
2 changes: 1 addition & 1 deletion anitya/tests/test_flask_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def test_api_get_version(self):
exp = {
"error": [
"geany: no upstream version found. "
"- https://www.geany.org/Down - "
"- https://www.geany.org/Down -"
" " + REGEX % ({"name": "geany"})
],
"output": "notok",
Expand Down
2 changes: 1 addition & 1 deletion anitya/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def projects_updated(status="updated"):
if status not in statuses:
flask.flash(
f"{status} is invalid, you should use one of: "
f"{', '.join(statuses)}; using default: `updated`",
f"{', '.join(statuses)}; using default: `updated`", # noqa: E702
"errors",
)
flask.flash(
Expand Down

0 comments on commit 28ae45c

Please sign in to comment.