From 28ae45c1d038cb188844ec08cd07cdd449f410d4 Mon Sep 17 00:00:00 2001 From: Michal Konecny Date: Thu, 1 Aug 2024 12:54:40 +0200 Subject: [PATCH] Fix pre-commit tests Signed-off-by: Michal Konecny --- .../versions/3fae8239eeec_add_an_api_token_table.py | 4 ++-- anitya/db/migrations/versions/a52d2fe99d4f_users.py | 4 ++-- .../b9201d816075_remove_the_backends_and_ecosystems_.py | 6 ++++-- .../versions/feeaa70ead67_social_authentication_table.py | 4 ++-- anitya/db/models.py | 4 ++-- anitya/lib/backends/__init__.py | 4 ++-- anitya/lib/backends/bitbucket.py | 2 +- anitya/lib/backends/cpan.py | 4 ++-- anitya/lib/backends/cran.py | 4 ++-- anitya/lib/backends/crates.py | 2 +- anitya/lib/backends/debian.py | 2 +- anitya/lib/backends/drupal6.py | 2 +- anitya/lib/backends/drupal7.py | 2 +- anitya/lib/backends/github.py | 4 ++-- anitya/lib/backends/gnome.py | 2 +- anitya/lib/backends/gnu.py | 2 +- anitya/lib/backends/hackage.py | 2 +- anitya/lib/backends/launchpad.py | 2 +- anitya/lib/backends/npmjs.py | 4 +++- anitya/lib/backends/pagure.py | 2 +- anitya/lib/backends/pear.py | 2 +- anitya/lib/backends/pecl.py | 2 +- anitya/lib/backends/pypi.py | 4 ++-- anitya/lib/backends/rubygems.py | 4 ++-- anitya/lib/backends/sourceforge_git.py | 2 +- anitya/lib/backends/sourcehut.py | 2 +- anitya/lib/backends/stackage.py | 4 ++-- anitya/tests/test_flask_api.py | 2 +- anitya/ui.py | 2 +- 29 files changed, 45 insertions(+), 41 deletions(-) diff --git a/anitya/db/migrations/versions/3fae8239eeec_add_an_api_token_table.py b/anitya/db/migrations/versions/3fae8239eeec_add_an_api_token_table.py index bf0560ac..071edb99 100644 --- a/anitya/db/migrations/versions/3fae8239eeec_add_an_api_token_table.py +++ b/anitya/db/migrations/versions/3fae8239eeec_add_an_api_token_table.py @@ -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): """ diff --git a/anitya/db/migrations/versions/a52d2fe99d4f_users.py b/anitya/db/migrations/versions/a52d2fe99d4f_users.py index 773dfc6c..9c5bab12 100644 --- a/anitya/db/migrations/versions/a52d2fe99d4f_users.py +++ b/anitya/db/migrations/versions/a52d2fe99d4f_users.py @@ -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): """ diff --git a/anitya/db/migrations/versions/b9201d816075_remove_the_backends_and_ecosystems_.py b/anitya/db/migrations/versions/b9201d816075_remove_the_backends_and_ecosystems_.py index 2b90bb44..f30e998a 100644 --- a/anitya/db/migrations/versions/b9201d816075_remove_the_backends_and_ecosystems_.py +++ b/anitya/db/migrations/versions/b9201d816075_remove_the_backends_and_ecosystems_.py @@ -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", @@ -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( diff --git a/anitya/db/migrations/versions/feeaa70ead67_social_authentication_table.py b/anitya/db/migrations/versions/feeaa70ead67_social_authentication_table.py index f2ad3001..a029fecc 100644 --- a/anitya/db/migrations/versions/feeaa70ead67_social_authentication_table.py +++ b/anitya/db/migrations/versions/feeaa70ead67_social_authentication_table.py @@ -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): """ diff --git a/anitya/db/models.py b/anitya/db/models.py index 4892e6d1..394892e3 100644 --- a/anitya/db/models.py +++ b/anitya/db/models.py @@ -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): """ diff --git a/anitya/lib/backends/__init__.py b/anitya/lib/backends/__init__.py index dfe726e4..4dda2729 100644 --- a/anitya/lib/backends/__init__.py +++ b/anitya/lib/backends/__init__.py @@ -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( diff --git a/anitya/lib/backends/bitbucket.py b/anitya/lib/backends/bitbucket.py index feb6f8c9..ac21a425 100644 --- a/anitya/lib/backends/bitbucket.py +++ b/anitya/lib/backends/bitbucket.py @@ -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 diff --git a/anitya/lib/backends/cpan.py b/anitya/lib/backends/cpan.py index 9af3b14e..3b221ded 100644 --- a/anitya/lib/backends/cpan.py +++ b/anitya/lib/backends/cpan.py @@ -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 @@ -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 diff --git a/anitya/lib/backends/cran.py b/anitya/lib/backends/cran.py index f2682371..1aaba0e0 100644 --- a/anitya/lib/backends/cran.py +++ b/anitya/lib/backends/cran.py @@ -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: @@ -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 diff --git a/anitya/lib/backends/crates.py b/anitya/lib/backends/crates.py index d2df380a..c8214fc7 100644 --- a/anitya/lib/backends/crates.py +++ b/anitya/lib/backends/crates.py @@ -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 diff --git a/anitya/lib/backends/debian.py b/anitya/lib/backends/debian.py index 0ff50c6e..47ee3f17 100644 --- a/anitya/lib/backends/debian.py +++ b/anitya/lib/backends/debian.py @@ -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): diff --git a/anitya/lib/backends/drupal6.py b/anitya/lib/backends/drupal6.py index 3b42d4a5..207d9f99 100644 --- a/anitya/lib/backends/drupal6.py +++ b/anitya/lib/backends/drupal6.py @@ -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 diff --git a/anitya/lib/backends/drupal7.py b/anitya/lib/backends/drupal7.py index b3505627..e19ee712 100644 --- a/anitya/lib/backends/drupal7.py +++ b/anitya/lib/backends/drupal7.py @@ -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): diff --git a/anitya/lib/backends/github.py b/anitya/lib/backends/github.py index 16f85f82..d37e8da2 100644 --- a/anitya/lib/backends/github.py +++ b/anitya/lib/backends/github.py @@ -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" @@ -317,6 +317,6 @@ def prepare_query(owner, repo, releases_only): remaining resetAt }} -}}""" +}}""" # noqa: E202 return query diff --git a/anitya/lib/backends/gnome.py b/anitya/lib/backends/gnome.py index 7f1a33d4..a869886d 100644 --- a/anitya/lib/backends/gnome.py +++ b/anitya/lib/backends/gnome.py @@ -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 diff --git a/anitya/lib/backends/gnu.py b/anitya/lib/backends/gnu.py index 61dc7a66..ecc3ece7 100644 --- a/anitya/lib/backends/gnu.py +++ b/anitya/lib/backends/gnu.py @@ -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 diff --git a/anitya/lib/backends/hackage.py b/anitya/lib/backends/hackage.py index 7e683a51..47789010 100644 --- a/anitya/lib/backends/hackage.py +++ b/anitya/lib/backends/hackage.py @@ -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 diff --git a/anitya/lib/backends/launchpad.py b/anitya/lib/backends/launchpad.py index 96b225b0..eeafa24c 100644 --- a/anitya/lib/backends/launchpad.py +++ b/anitya/lib/backends/launchpad.py @@ -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 diff --git a/anitya/lib/backends/npmjs.py b/anitya/lib/backends/npmjs.py index e5c79366..c9e0f5e5 100644 --- a/anitya/lib/backends/npmjs.py +++ b/anitya/lib/backends/npmjs.py @@ -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 diff --git a/anitya/lib/backends/pagure.py b/anitya/lib/backends/pagure.py index 25bbea7f..68233577 100644 --- a/anitya/lib/backends/pagure.py +++ b/anitya/lib/backends/pagure.py @@ -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 diff --git a/anitya/lib/backends/pear.py b/anitya/lib/backends/pear.py index 2368dcde..c3b1dc61 100644 --- a/anitya/lib/backends/pear.py +++ b/anitya/lib/backends/pear.py @@ -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 diff --git a/anitya/lib/backends/pecl.py b/anitya/lib/backends/pecl.py index 99ab715f..475fb624 100644 --- a/anitya/lib/backends/pecl.py +++ b/anitya/lib/backends/pecl.py @@ -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 diff --git a/anitya/lib/backends/pypi.py b/anitya/lib/backends/pypi.py index c3d1fcfd..c73f9626 100644 --- a/anitya/lib/backends/pypi.py +++ b/anitya/lib/backends/pypi.py @@ -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 @@ -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 diff --git a/anitya/lib/backends/rubygems.py b/anitya/lib/backends/rubygems.py index 5ed75bd3..198e2958 100644 --- a/anitya/lib/backends/rubygems.py +++ b/anitya/lib/backends/rubygems.py @@ -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 @@ -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 diff --git a/anitya/lib/backends/sourceforge_git.py b/anitya/lib/backends/sourceforge_git.py index b9b5e28c..f25d2b69 100644 --- a/anitya/lib/backends/sourceforge_git.py +++ b/anitya/lib/backends/sourceforge_git.py @@ -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 diff --git a/anitya/lib/backends/sourcehut.py b/anitya/lib/backends/sourcehut.py index 2d9f45b0..68470fc2 100644 --- a/anitya/lib/backends/sourcehut.py +++ b/anitya/lib/backends/sourcehut.py @@ -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) diff --git a/anitya/lib/backends/stackage.py b/anitya/lib/backends/stackage.py index 27458e09..58ca10b4 100644 --- a/anitya/lib/backends/stackage.py +++ b/anitya/lib/backends/stackage.py @@ -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 @@ -54,7 +54,7 @@ def get_versions(cls, project): url = cls.get_version_url(project) regex = ( - rf"" + rf"" # noqa: E231 r"([\d.]*).*" ) diff --git a/anitya/tests/test_flask_api.py b/anitya/tests/test_flask_api.py index 2dbad35e..211cf915 100644 --- a/anitya/tests/test_flask_api.py +++ b/anitya/tests/test_flask_api.py @@ -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", diff --git a/anitya/ui.py b/anitya/ui.py index 6d9c8fe2..8a3df5b8 100644 --- a/anitya/ui.py +++ b/anitya/ui.py @@ -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(