From 221dff44e866974e337f820402296413dc1e97ac Mon Sep 17 00:00:00 2001 From: "geo-ghci-int[bot]" <146321879+geo-ghci-int[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:19:00 +0000 Subject: [PATCH] Apply pre-commit fix From the artifact of the previous workflow run --- .../application_configuration.py | 4 +-- github_app_geo_project/configuration.py | 4 +-- .../module/audit/__init__.py | 7 ++---- .../module/audit/configuration.py | 4 +-- github_app_geo_project/module/audit/utils.py | 25 +++++++------------ .../delete_old_workflow_runs/configuration.py | 4 +-- github_app_geo_project/module/modules.py | 4 +-- .../module/pull_request/__init__.py | 4 +-- .../module/pull_request/checks.py | 4 +-- .../pull_request/checks_configuration.py | 4 +-- .../module/pull_request/links.py | 2 +- .../pull_request/links_configuration.py | 4 +-- .../module/standard/auto_configuration.py | 4 +-- .../module/standard/changelog.py | 19 ++++---------- .../standard/changelog_configuration.py | 4 +-- github_app_geo_project/module/utils.py | 10 +++++--- .../module/versions/__init__.py | 5 ++-- .../module/versions/configuration.py | 4 +-- .../project_configuration.py | 4 +-- github_app_geo_project/scripts/__init__.py | 4 +-- .../scripts/health_check.py | 8 ++---- .../scripts/process_queue.py | 11 ++++---- github_app_geo_project/scripts/send_event.py | 4 +-- github_app_geo_project/security.py | 2 +- .../static/favicon_color.py | 4 +-- github_app_geo_project/templates/__init__.py | 20 ++++----------- github_app_geo_project/views/home.py | 6 +++-- github_app_geo_project/views/project.py | 1 - github_app_geo_project/views/webhook.py | 2 -- tests/test_module_utils.py | 22 ++++++++-------- tests/test_module_versions.py | 5 +--- tests/test_template.py | 2 +- 32 files changed, 71 insertions(+), 140 deletions(-) diff --git a/github_app_geo_project/application_configuration.py b/github_app_geo_project/application_configuration.py index 6e2d412a2ca..dc7d5e40452 100644 --- a/github_app_geo_project/application_configuration.py +++ b/github_app_geo_project/application_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import Any, TypedDict diff --git a/github_app_geo_project/configuration.py b/github_app_geo_project/configuration.py index 7432110d86b..96ba4aa5fcf 100644 --- a/github_app_geo_project/configuration.py +++ b/github_app_geo_project/configuration.py @@ -20,9 +20,7 @@ def apply_profile_inheritance(profile_name: str, profiles: dict[str, Any]) -> None: - """ - Apply the inheritance of the profile. - """ + """Apply the inheritance of the profile.""" for other_name, other_profile in APPLICATION_CONFIGURATION["profiles"].items(): if other_profile.get("inherits") == profile_name: _LOGGER.debug("Apply inheritance %s -> %s", profile_name, other_name) diff --git a/github_app_geo_project/module/audit/__init__.py b/github_app_geo_project/module/audit/__init__.py index 36e76863dc7..170068943aa 100644 --- a/github_app_geo_project/module/audit/__init__.py +++ b/github_app_geo_project/module/audit/__init__.py @@ -163,10 +163,7 @@ async def _process_snyk_dpkg( python_version = ".".join(line.split(" ")[1].split(".")[0:2]).strip() break - if python_version: - env = _use_python_version(python_version) - else: - env = os.environ.copy() + env = _use_python_version(python_version) if python_version else os.environ.copy() result, body, short_message, new_success = await audit_utils.snyk( branch, @@ -186,7 +183,7 @@ async def _process_snyk_dpkg( ", ".join(short_message), ) message: module_utils.Message = module_utils.HtmlMessage( - "Output" % output_url + f"Output" ) message.title = "Output URL" _LOGGER.debug(message) diff --git a/github_app_geo_project/module/audit/configuration.py b/github_app_geo_project/module/audit/configuration.py index 8343cd29e1c..0b089eef19e 100644 --- a/github_app_geo_project/module/audit/configuration.py +++ b/github_app_geo_project/module/audit/configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import Any, Literal, TypedDict, Union diff --git a/github_app_geo_project/module/audit/utils.py b/github_app_geo_project/module/audit/utils.py index 161fa1658ca..83c33db3813 100644 --- a/github_app_geo_project/module/audit/utils.py +++ b/github_app_geo_project/module/audit/utils.py @@ -1,6 +1,4 @@ -""" -The auditing functions. -""" +"""The auditing functions.""" import asyncio import datetime @@ -128,7 +126,6 @@ async def _select_java_version( local_config: configuration.SnykConfiguration, env: dict[str, str], ) -> None: - if not os.path.exists("gradlew"): return @@ -607,9 +604,7 @@ async def _npm_audit_fix( def outdated_versions( security: security_md.Security, ) -> list[str | models.OutputData]: - """ - Check that the versions from the SECURITY.md are not outdated. - """ + """Check that the versions from the SECURITY.md are not outdated.""" version_index = security.headers.index("Version") date_index = security.headers.index("Supported Until") @@ -635,9 +630,7 @@ def outdated_versions( def _get_sources( dist: str, config: configuration.DpkgConfiguration, local_config: configuration.DpkgConfiguration ) -> apt_repo.APTSources: - """ - Get the sources for the distribution. - """ + """Get the sources for the distribution.""" if dist not in _SOURCES: conf = local_config.get("sources", config.get("sources", configuration.DPKG_SOURCES_DEFAULT)) if dist not in conf: @@ -657,9 +650,7 @@ def _get_sources( name = f"{dist}/{package.package}" try: version = debian_inspector.version.Version.from_string(package.version) - if name not in _PACKAGE_VERSION: - _PACKAGE_VERSION[name] = version - elif version > _PACKAGE_VERSION[name]: + if name not in _PACKAGE_VERSION or version > _PACKAGE_VERSION[name]: _PACKAGE_VERSION[name] = version except ValueError as exception: _LOGGER.warning( @@ -680,8 +671,10 @@ async def _get_packages_version( ) -> str | None: """Get the version of the package.""" global _GENERATION_TIME # pylint: disable=global-statement - if _GENERATION_TIME is None or _GENERATION_TIME < datetime.datetime.now() - utils.parse_duration( - os.environ.get("GHCI_DPKG_CACHE_DURATION", "3h") + if ( + _GENERATION_TIME is None + or datetime.datetime.now() - utils.parse_duration(os.environ.get("GHCI_DPKG_CACHE_DURATION", "3h")) + > _GENERATION_TIME ): _PACKAGE_VERSION.clear() _SOURCES.clear() @@ -709,7 +702,7 @@ async def dpkg( with open(dpkg_versions_filename, encoding="utf-8") as versions_file: versions_config = yaml.load(versions_file, Loader=yaml.SafeLoader) for versions in versions_config.values(): - for package_full in versions.keys(): + for package_full in versions: version = await _get_packages_version(package_full, config, local_config) if version is None: _LOGGER.warning("No version found for %s", package_full) diff --git a/github_app_geo_project/module/delete_old_workflow_runs/configuration.py b/github_app_geo_project/module/delete_old_workflow_runs/configuration.py index e4913d40639..39262243f77 100644 --- a/github_app_geo_project/module/delete_old_workflow_runs/configuration.py +++ b/github_app_geo_project/module/delete_old_workflow_runs/configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import TypedDict diff --git a/github_app_geo_project/module/modules.py b/github_app_geo_project/module/modules.py index d521493fe99..eccebe6618c 100644 --- a/github_app_geo_project/module/modules.py +++ b/github_app_geo_project/module/modules.py @@ -1,6 +1,4 @@ -""" -Module registry. -""" +"""Module registry.""" import logging from typing import Any diff --git a/github_app_geo_project/module/pull_request/__init__.py b/github_app_geo_project/module/pull_request/__init__.py index 7a8a4327250..28c6ab49dfd 100644 --- a/github_app_geo_project/module/pull_request/__init__.py +++ b/github_app_geo_project/module/pull_request/__init__.py @@ -1,3 +1 @@ -""" -The modules related to the pull request. -""" +"""The modules related to the pull request.""" diff --git a/github_app_geo_project/module/pull_request/checks.py b/github_app_geo_project/module/pull_request/checks.py index a71f9754287..b45c10c815c 100644 --- a/github_app_geo_project/module/pull_request/checks.py +++ b/github_app_geo_project/module/pull_request/checks.py @@ -31,9 +31,7 @@ def _get_code_spell_command( ], ignore_file: NamedTemporaryFileStr, ) -> list[str]: - """ - Get the codespell command. - """ + """Get the codespell command.""" config = context.module_config code_spell_config = config.get("codespell", {}) code_spell_config = code_spell_config if isinstance(code_spell_config, dict) else {} diff --git a/github_app_geo_project/module/pull_request/checks_configuration.py b/github_app_geo_project/module/pull_request/checks_configuration.py index 257a0c9cf65..e454f737e13 100644 --- a/github_app_geo_project/module/pull_request/checks_configuration.py +++ b/github_app_geo_project/module/pull_request/checks_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import TypedDict, Union diff --git a/github_app_geo_project/module/pull_request/links.py b/github_app_geo_project/module/pull_request/links.py index c2c14dae06c..e4c18aa6d91 100644 --- a/github_app_geo_project/module/pull_request/links.py +++ b/github_app_geo_project/module/pull_request/links.py @@ -8,7 +8,7 @@ import github import github.PullRequest -from github_app_geo_project import configuration, module +from github_app_geo_project import module from github_app_geo_project.module.pull_request import links_configuration diff --git a/github_app_geo_project/module/pull_request/links_configuration.py b/github_app_geo_project/module/pull_request/links_configuration.py index 64035949409..d7b97a95946 100644 --- a/github_app_geo_project/module/pull_request/links_configuration.py +++ b/github_app_geo_project/module/pull_request/links_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import TypedDict diff --git a/github_app_geo_project/module/standard/auto_configuration.py b/github_app_geo_project/module/standard/auto_configuration.py index aa21a22673e..21ef8ccf125 100644 --- a/github_app_geo_project/module/standard/auto_configuration.py +++ b/github_app_geo_project/module/standard/auto_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import TypedDict diff --git a/github_app_geo_project/module/standard/changelog.py b/github_app_geo_project/module/standard/changelog.py index 78e6ff41465..17c2ac16a77 100644 --- a/github_app_geo_project/module/standard/changelog.py +++ b/github_app_geo_project/module/standard/changelog.py @@ -98,18 +98,12 @@ def match(item: ChangelogItem, condition: Condition) -> bool: def match_and(item: ChangelogItem, condition: changelog_configuration.ConditionAndSolidusOr) -> bool: """Match all the conditions.""" - for cond in condition["conditions"]: - if not match(item, cond): - return False - return True + return all(match(item, cond) for cond in condition["conditions"]) def match_or(item: ChangelogItem, condition: changelog_configuration.ConditionAndSolidusOr) -> bool: """Match any of the conditions.""" - for cond in condition["conditions"]: - if match(item, cond): - return True - return False + return any(match(item, cond) for cond in condition["conditions"]) def match_not(item: ChangelogItem, condition: changelog_configuration.ConditionNot) -> bool: @@ -131,10 +125,7 @@ def match_title(item: ChangelogItem, condition: changelog_configuration.Conditio def match_files(item: ChangelogItem, condition: changelog_configuration.ConditionFiles) -> bool: """Match all the files of the pull request.""" file_re = re.compile("|".join(condition["regex"])) - for file_name in item.files: - if file_re.match(file_name) is None: - return False - return True + return all(file_re.match(file_name) is not None for file_name in item.files) def match_label(item: ChangelogItem, condition: changelog_configuration.ConditionLabel) -> bool: @@ -255,7 +246,7 @@ def _previous_tag(tag: Tag, tags: dict[Tag, Tag]) -> Tag | None: return _previous_tag(test_tag, tags) if tag.major != 0: # Get previous version - tags_list = sorted([t for t in tags.keys() if t.major < tag.major]) + tags_list = sorted([t for t in tags if t.major < tag.major]) if not tags_list: return None previous_major_minor = tags_list[-1] @@ -264,7 +255,7 @@ def _previous_tag(tag: Tag, tags: dict[Tag, Tag]) -> Tag | None: tags_list = sorted( [ t - for t in tags.keys() + for t in tags if t.major == previous_major_minor.major and t.minor == previous_major_minor.minor ] ) diff --git a/github_app_geo_project/module/standard/changelog_configuration.py b/github_app_geo_project/module/standard/changelog_configuration.py index aa2d23a099e..cba3b1f3406 100644 --- a/github_app_geo_project/module/standard/changelog_configuration.py +++ b/github_app_geo_project/module/standard/changelog_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import Literal, TypedDict, Union diff --git a/github_app_geo_project/module/utils.py b/github_app_geo_project/module/utils.py index a5a62291de3..64e721b7a4e 100644 --- a/github_app_geo_project/module/utils.py +++ b/github_app_geo_project/module/utils.py @@ -7,7 +7,7 @@ import re import shlex import subprocess # nosec -from typing import Any, Union, cast +from typing import Any, cast import github import html_sanitizer @@ -56,7 +56,7 @@ def __init__(self, title: str, comment: str = "", checked: bool | None = None) - self.checked = checked -DashboardIssueRaw = list[Union[DashboardIssueItem, str]] +DashboardIssueRaw = list[DashboardIssueItem | str] _CHECK_RE = re.compile(r"- \[([ x])\] (.*)") _COMMENT_RE = re.compile(r"^(.*)(.*)$") @@ -643,7 +643,8 @@ def create_pull_request( body = f"See: #{pull_request.number}" found = False issues = project.repo.get_issues( - state="open", creator=project.application.integration.get_app().slug + "[bot]" # type: ignore[arg-type] + state="open", + creator=project.application.integration.get_app().slug + "[bot]", # type: ignore[arg-type] ) if issues.totalCount > 0: for candidate in issues: @@ -707,7 +708,8 @@ def close_pull_request_issues(new_branch: str, message: str, project: configurat title = f"Pull request {message} is open for 5 days" issues = project.repo.get_issues( - state="open", creator=project.application.integration.get_app().slug + "[bot]" # type: ignore[arg-type] + state="open", + creator=project.application.integration.get_app().slug + "[bot]", # type: ignore[arg-type] ) for issue in issues: if title == issue.title: diff --git a/github_app_geo_project/module/versions/__init__.py b/github_app_geo_project/module/versions/__init__.py index 4c50ca05701..c627827023d 100644 --- a/github_app_geo_project/module/versions/__init__.py +++ b/github_app_geo_project/module/versions/__init__.py @@ -456,9 +456,8 @@ def _get_names( names = names_by_datasource.setdefault("pypi", _TransversalStatusNameByDatasource()).names for line in file: match = re.match(r'^ *name ?= ?[\'"](.*)[\'"],?$', line) - if match: - if match.group(1) not in names: - names.append(match.group(1)) + if match and match.group(1) not in names: + names.append(match.group(1)) os.environ["GITHUB_REPOSITORY"] = f"{context.github_project.owner}/{context.github_project.repository}" data = c2cciutils.get_config() docker_config = data.get("publish", {}).get("docker", {}) diff --git a/github_app_geo_project/module/versions/configuration.py b/github_app_geo_project/module/versions/configuration.py index 7010494552c..293f59b631d 100644 --- a/github_app_geo_project/module/versions/configuration.py +++ b/github_app_geo_project/module/versions/configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import Any, TypedDict diff --git a/github_app_geo_project/project_configuration.py b/github_app_geo_project/project_configuration.py index 723d14df09a..a1c55a521d8 100644 --- a/github_app_geo_project/project_configuration.py +++ b/github_app_geo_project/project_configuration.py @@ -1,6 +1,4 @@ -""" -Automatically generated file from a JSON schema. -""" +"""Automatically generated file from a JSON schema.""" from typing import TypedDict diff --git a/github_app_geo_project/scripts/__init__.py b/github_app_geo_project/scripts/__init__.py index 14a07769ed2..5e1d4fc098a 100644 --- a/github_app_geo_project/scripts/__init__.py +++ b/github_app_geo_project/scripts/__init__.py @@ -1,3 +1 @@ -""" -The scripts module. -""" +"""The scripts module.""" diff --git a/github_app_geo_project/scripts/health_check.py b/github_app_geo_project/scripts/health_check.py index 4904157188d..b607dedc050 100644 --- a/github_app_geo_project/scripts/health_check.py +++ b/github_app_geo_project/scripts/health_check.py @@ -1,6 +1,4 @@ -""" -Script used to check the health of the process-queue daemon. -""" +"""Script used to check the health of the process-queue daemon.""" import argparse import os @@ -10,9 +8,7 @@ def main() -> None: - """ - Check the health of the process-queue daemon. - """ + """Check the health of the process-queue daemon.""" parser = argparse.ArgumentParser(description="Check the health of the process-queue daemon") parser.add_argument("--timeout", type=int, help="Timeout in seconds") args = parser.parse_args() diff --git a/github_app_geo_project/scripts/process_queue.py b/github_app_geo_project/scripts/process_queue.py index aec3a2a7c1d..76e0de347e8 100644 --- a/github_app_geo_project/scripts/process_queue.py +++ b/github_app_geo_project/scripts/process_queue.py @@ -1,6 +1,4 @@ -""" -Process the jobs present in the database queue. -""" +"""Process the jobs present in the database queue.""" import argparse import asyncio @@ -23,7 +21,7 @@ import prometheus_client.exposition import sentry_sdk import sqlalchemy.orm -from prometheus_client import Gauge, Info +from prometheus_client import Gauge from github_app_geo_project import configuration, models, module, project_configuration, utils from github_app_geo_project.module import modules @@ -102,7 +100,7 @@ def _validate_job(config: dict[str, Any], application: str, event_data: dict[str github_application = configuration.get_github_application(config, application) github_app = github_application.integration.get_app() installation_id = event_data.get("installation", {}).get("id", 0) - if not github_app.id != installation_id: + if github_app.id == installation_id: _LOGGER.error("Invalid installation id %i != %i", github_app.id, installation_id) return False return True @@ -510,7 +508,8 @@ def _get_dashboard_issue( github_application: configuration.GithubApplication, repo: github.Repository.Repository ) -> github.Issue.Issue | None: open_issues = repo.get_issues( - state="open", creator=github_application.integration.get_app().slug + "[bot]" # type: ignore[arg-type] + state="open", + creator=github_application.integration.get_app().slug + "[bot]", # type: ignore[arg-type] ) if open_issues.totalCount > 0: for candidate in open_issues: diff --git a/github_app_geo_project/scripts/send_event.py b/github_app_geo_project/scripts/send_event.py index 8006af7f232..6fad07fbe22 100644 --- a/github_app_geo_project/scripts/send_event.py +++ b/github_app_geo_project/scripts/send_event.py @@ -1,6 +1,4 @@ -""" -Send an event in the database queue. -""" +"""Send an event in the database queue.""" import argparse diff --git a/github_app_geo_project/security.py b/github_app_geo_project/security.py index 1c81e2fbcb2..34ddff2550a 100644 --- a/github_app_geo_project/security.py +++ b/github_app_geo_project/security.py @@ -108,7 +108,7 @@ def identity(self, request: pyramid.request.Request) -> User: else: user = User("anonymous", None, None, None, False, None, request) - setattr(request, "user", user) + request.user = user return request.user # type: ignore diff --git a/github_app_geo_project/static/favicon_color.py b/github_app_geo_project/static/favicon_color.py index 74f3e548c2c..18cb66f3550 100644 --- a/github_app_geo_project/static/favicon_color.py +++ b/github_app_geo_project/static/favicon_color.py @@ -1,6 +1,4 @@ -""" -Used to generate different color favicons for the website. -""" +"""Used to generate different color favicons for the website.""" import cv2 # pylint: disable=import-error diff --git a/github_app_geo_project/templates/__init__.py b/github_app_geo_project/templates/__init__.py index 036fb889d16..48fe2c9ff82 100644 --- a/github_app_geo_project/templates/__init__.py +++ b/github_app_geo_project/templates/__init__.py @@ -10,9 +10,7 @@ def sanitizer(text: str) -> str: - """ - Sanitize the input string. - """ + """Sanitize the input string.""" sanitizer_instance = html_sanitizer.Sanitizer( { "tags": html_sanitizer.sanitizer.DEFAULT_SETTINGS["tags"] | {"span", "div", "pre", "code"}, @@ -47,16 +45,12 @@ def sanitizer(text: str) -> str: def markdown(text: str) -> str: - """ - Convert the input string to markdown. - """ + """Convert the input string to markdown.""" return sanitizer(markdown_lib.markdown(text)) def pprint_short_date(date_in: str | datetime) -> str: - """ - Pretty print a short date (essentially time to current time). - """ + """Pretty print a short date (essentially time to current time).""" if date_in == "None" or date_in is None: return "-" @@ -80,9 +74,7 @@ def pprint_short_date(date_in: str | datetime) -> str: def pprint_full_date(date_in: str | datetime) -> str: - """ - Pretty print a full date. - """ + """Pretty print a full date.""" if date_in == "None" or date_in is None: return "-" @@ -106,9 +98,7 @@ def pprint_date(date_in: str | datetime) -> str: def pprint_duration(duration_in: str | timedelta) -> str: - """ - Pretty print a duration. - """ + """Pretty print a duration.""" if duration_in == "None" or duration_in is None: return "-" diff --git a/github_app_geo_project/views/home.py b/github_app_geo_project/views/home.py index 6ee0e996bd4..aff1aae30c3 100644 --- a/github_app_geo_project/views/home.py +++ b/github_app_geo_project/views/home.py @@ -119,7 +119,8 @@ def output(request: pyramid.request.Request) -> dict[str, Any]: # Test that all permissions are in github_permissions for permission, access in permissions.items(): if permission not in github_permissions or _gt_access( - access, github_permissions[permission] # type: ignore[arg-type,literal-required] + access, + github_permissions[permission], # type: ignore[arg-type,literal-required] ): application["errors"].append( f"Missing permission ({permission}={access}) in the GitHub application, " @@ -137,7 +138,8 @@ def output(request: pyramid.request.Request) -> dict[str, Any]: "\n".join([f"{k}={v}" for k, v in github_permissions.items()]), ) elif _gt_access( - github_permissions[permission], access # type: ignore[arg-type,literal-required] + github_permissions[permission], + access, # type: ignore[arg-type,literal-required] ): _LOGGER.error( "The GitHub application '%s' has more permission (%s=%s) than required, " diff --git a/github_app_geo_project/views/project.py b/github_app_geo_project/views/project.py index b2e9644d2ca..78a06d84d7d 100644 --- a/github_app_geo_project/views/project.py +++ b/github_app_geo_project/views/project.py @@ -10,7 +10,6 @@ import pyramid.response import pyramid.security import sqlalchemy -import yaml from pyramid.view import view_config from github_app_geo_project import configuration, models, project_configuration, utils diff --git a/github_app_geo_project/views/webhook.py b/github_app_geo_project/views/webhook.py index 30f2001ff2d..068febc0162 100644 --- a/github_app_geo_project/views/webhook.py +++ b/github_app_geo_project/views/webhook.py @@ -11,7 +11,6 @@ import pyramid.request import sqlalchemy.engine import sqlalchemy.orm -from numpy import where from pyramid.view import view_config from sqlalchemy.orm import Session @@ -236,7 +235,6 @@ def process_event(context: ProcessContext) -> None: jobs_unique_on = current_module.jobs_unique_on() if jobs_unique_on: - update = ( sqlalchemy.update(models.Queue) .where(models.Queue.status == models.JobStatus.NEW) diff --git a/tests/test_module_utils.py b/tests/test_module_utils.py index 90657e6591a..522979181a5 100644 --- a/tests/test_module_utils.py +++ b/tests/test_module_utils.py @@ -12,11 +12,11 @@ def test_parse_dashboard_issue() -> None: assert isinstance(result[1], utils.DashboardIssueItem) assert result[1].title == "title" assert result[1].comment == "comment" - assert result[1].checked == True + assert result[1].checked is True assert isinstance(result[2], utils.DashboardIssueItem) assert result[2].title == "title2" assert result[2].comment == "" - assert result[2].checked == False + assert result[2].checked is False assert result[3] == "other" @@ -36,26 +36,26 @@ def test_dashboard_issue() -> None: dashboard_issue = utils.DashboardIssue(issue_data) # Test is_checked - assert dashboard_issue.is_checked("comment") == True - assert dashboard_issue.is_checked("nonexistent") == None + assert dashboard_issue.is_checked("comment") is True + assert dashboard_issue.is_checked("nonexistent") is None # Test get_title assert dashboard_issue.get_title("comment") == "title" - assert dashboard_issue.get_title("nonexistent") == None + assert dashboard_issue.get_title("nonexistent") is None # Test set_check - assert dashboard_issue.set_check("comment", False) == True - assert dashboard_issue.is_checked("comment") == False - assert dashboard_issue.set_check("nonexistent", False) == False + assert dashboard_issue.set_check("comment", False) is True + assert dashboard_issue.is_checked("comment") is False + assert dashboard_issue.set_check("nonexistent", False) is False # Test set_title - assert dashboard_issue.set_title("comment", "new title") == True + assert dashboard_issue.set_title("comment", "new title") is True assert dashboard_issue.get_title("comment") == "new title" - assert dashboard_issue.set_title("nonexistent", "new title") == False + assert dashboard_issue.set_title("nonexistent", "new title") is False # Test add_check dashboard_issue.add_check("new", "new title", True) - assert dashboard_issue.is_checked("new") == True + assert dashboard_issue.is_checked("new") is True assert dashboard_issue.get_title("new") == "new title" # Test to_string and __str__ diff --git a/tests/test_module_versions.py b/tests/test_module_versions.py index 353d0dfc9ec..2e7e8d2c5f3 100644 --- a/tests/test_module_versions.py +++ b/tests/test_module_versions.py @@ -5,7 +5,6 @@ import responses from github_app_geo_project.module.versions import ( - ProcessOutput, Versions, _canonical_minor_version, _Dependencies, @@ -56,9 +55,7 @@ async def test_process_step_2() -> None: context.github_project.repository = "test" context.module_config = {} os.environ["TEST"] = "TRUE" - os.environ[ - "RENOVATE_GRAPH" - ] = """WARN: GitHub token is required for some dependencies + os.environ["RENOVATE_GRAPH"] = """WARN: GitHub token is required for some dependencies "githubDeps": [ "camptocamp/backport-action", "actions/checkout", diff --git a/tests/test_template.py b/tests/test_template.py index 3240626d003..7edeb0b9feb 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta, timezone -from github_app_geo_project.templates import markdown, markdown_lib, pprint_date, pprint_duration, sanitizer +from github_app_geo_project.templates import markdown, pprint_date, pprint_duration, sanitizer def test_sanitizer() -> None: