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

Fix UnboundLocalError in errata endpoint #868

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

Korulag
Copy link
Contributor

@Korulag Korulag commented Jun 12, 2024

Build URL was created after the usage in "create_github_issue" function

Build URL was created after the usage in "create_github_issue" function
Copy link

github-actions bot commented Jun 12, 2024

73 passed, 11 skipped

Code Coverage Summary

Package Line Rate
alws 76%
alws.auth 77%
alws.auth.oauth 100%
alws.crud 41%
alws.dramatiq 60%
alws.middlewares 93%
alws.perms 86%
alws.routers 57%
alws.schemas 80%
alws.utils 41%
Summary 57% (5678 / 10016)

Linter reports

Pylint report
************* Module alws.config
alws/config.py:13:0: C0301: Line too long (85/80) (line-too-long)
alws/config.py:32:0: C0301: Line too long (86/80) (line-too-long)
alws/config.py:87:0: C0301: Line too long (92/80) (line-too-long)
alws/config.py:8:0: C0115: Missing class docstring (missing-class-docstring)
************* Module alws.utils.github_integration_helper
alws/utils/github_integration_helper.py:26:0: C0301: Line too long (83/80) (line-too-long)
alws/utils/github_integration_helper.py:51:0: C0301: Line too long (82/80) (line-too-long)
alws/utils/github_integration_helper.py:73:0: C0301: Line too long (82/80) (line-too-long)
alws/utils/github_integration_helper.py:181:0: C0301: Line too long (82/80) (line-too-long)
alws/utils/github_integration_helper.py:258:0: C0301: Line too long (82/80) (line-too-long)
alws/utils/github_integration_helper.py:32:8: W0719: Raising too general exception: Exception (broad-exception-raised)
alws/utils/github_integration_helper.py:235:0: C0116: Missing function or method docstring (missing-function-docstring)
alws/utils/github_integration_helper.py:235:0: R0914: Too many local variables (24/15) (too-many-locals)

-----------------------------------
Your code has been rated at 9.46/10


Black report
--- alws/config.py	2024-06-12 15:53:32.838956+00:00
+++ alws/config.py	2024-06-12 15:54:10.947521+00:00
@@ -8,11 +8,13 @@
 class Settings(BaseSettings):
     pulp_host: str = 'http://pulp'
     pulp_user: str = 'admin'
     pulp_password: str = 'admin'
     pulp_export_path: str = '/srv/exports'
-    pulp_database_url: str = 'postgresql+psycopg2://postgres:password@pulp:5432/pulp'
+    pulp_database_url: str = (
+        'postgresql+psycopg2://postgres:password@pulp:5432/pulp'
+    )
     pulp_async_database_url: str = (
         'postgresql+asyncpg://postgres:password@pulp:5432/pulp'
     )
 
     alts_host: str = 'http://alts-scheduler:8000'
@@ -27,11 +29,13 @@
 
     database_url: str = 'postgresql+asyncpg://postgres:password@db/almalinux-bs'
     test_database_url: str = (
         'postgresql+asyncpg://postgres:password@db/test-almalinux-bs'
     )
-    sync_database_url: str = 'postgresql+psycopg2://postgres:password@db/almalinux-bs'
+    sync_database_url: str = (
+        'postgresql+psycopg2://postgres:password@db/almalinux-bs'
+    )
 
     fastapi_sqla__async__sqlalchemy_url: str = (
         'postgresql+asyncpg://postgres:password@db/almalinux-bs'
     )
     fastapi_sqla__async__sqlalchemy_echo_pool: bool = True
@@ -82,11 +86,13 @@
 
     documentation_path: str = 'alws/documentation/'
 
     logging_level: Optional[str] = 'INFO'
 
-    frontend_baseurl: Annotated[str, Field(validate_default=True)] = 'http://localhost:8080'
+    frontend_baseurl: Annotated[str, Field(validate_default=True)] = (
+        'http://localhost:8080'
+    )
     github_callback_endpoint: str = 'api/v1/auth/github/callback'
     almalinux_callback_endpoint: str = 'api/v1/auth/almalinux/callback'
 
     sentry_environment: str = 'dev'
     sentry_dsn: Optional[str] = None
--- alws/utils/github_integration_helper.py	2024-06-12 15:53:32.842956+00:00
+++ alws/utils/github_integration_helper.py	2024-06-12 15:54:11.030846+00:00
@@ -21,14 +21,16 @@
         ]):
             raise ValueError(
                 'Config for GitHub integration is incomplete, '
                 'please check the settings'
             )
-        github_token = await IntegrationsGHGraphQLClient.generate_token_for_gh_app(
-            gh_app_id=app_id,
-            path_to_gh_app_pem=pem,
-            installation_id=installation_id,
+        github_token = (
+            await IntegrationsGHGraphQLClient.generate_token_for_gh_app(
+                gh_app_id=app_id,
+                path_to_gh_app_pem=pem,
+                installation_id=installation_id,
+            )
         )
     if not github_token:
         raise Exception("Can not get Github token")
 
     github_client = IntegrationsGHGraphQLClient(
@@ -46,11 +48,13 @@
     repo_names: list,
 ) -> typing.List[dict]:
     issue_ids = []
     for name in repo_names:
         query = f"conflict for {name} in:title"
-        issue_ids.extend(await get_github_issue_content_ids(github_client, query))
+        issue_ids.extend(
+            await get_github_issue_content_ids(github_client, query)
+        )
     issue_ids = set(issue_ids)
     project_issues = await github_client.get_project_content_issues()
     filtered_issues = []
     valid_statuses = [
         GitHubIssueStatus.TODO.value,
@@ -68,11 +72,13 @@
     record_ids: typing.List[str],
 ) -> typing.List[dict]:
     issue_ids = []
     for record_id in record_ids:
         query = f"{record_id} in:title"
-        issue_ids.extend(await get_github_issue_content_ids(github_client, query))
+        issue_ids.extend(
+            await get_github_issue_content_ids(github_client, query)
+        )
     project_issues = await github_client.get_project_content_issues()
     issues = []
     for issue_id in list(issue_ids):
         project_issue = project_issues[issue_id]
         issues.append(project_issue.model_dump())
@@ -176,11 +182,13 @@
 ):
     filtered = []
     for issue in issues:
         condition = []
         if valid_statuses:
-            condition.append(issue["fields"]["Status"]["value"] in valid_statuses)
+            condition.append(
+                issue["fields"]["Status"]["value"] in valid_statuses
+            )
         if platform:
             condition.append(issue["fields"]["Platform"]["value"] == platform)
         if all(condition):
             filtered.append(issue)
     return filtered
@@ -253,11 +261,13 @@
     issue_body = (
         f'{title}\nSeverity: {severity}\n'
         f'Description\n{description}\n\n'
         f'Affected packages:\n{packages_section}'
     )
-    issue_id, project_item_id = await client.create_issue(issue_title, issue_body)
+    issue_id, project_item_id = await client.create_issue(
+        issue_title, issue_body
+    )
     await client.set_issue_platform(project_item_id, platform_name)
     errata_url = urljoin(
         settings.frontend_baseurl,
         f"/errata?id={advisory_id}&platform_id={platform_id}",
     )

Bandit report
Run started:2024-06-12 15:54:12.730460

Test results:
	No issues identified.

Code scanned:
	Total lines of code: 371
	Total lines skipped (#nosec): 0
	Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
	Total issues (by severity):
		Undefined: 0
		Low: 0
		Medium: 0
		High: 0
	Total issues (by confidence):
		Undefined: 0
		Low: 0
		Medium: 0
		High: 0
Files skipped (0):

View full reports on the Job Summary page.

Copy link
Member

@soksanichenko soksanichenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a link to task

@Korulag Korulag force-pushed the fix-build-url-set branch from aa45b68 to 9909c0b Compare June 12, 2024 15:53
@Korulag Korulag merged commit acbdb05 into master Jul 2, 2024
2 checks passed
@Korulag Korulag deleted the fix-build-url-set branch July 2, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants