This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new 0f049a0  Parenthesize subexpressions consistently
0f049a0 is described below

commit 0f049a078838740198c3f4be4284465842d987fd
Author: Sean B. Palmer <[email protected]>
AuthorDate: Mon Dec 22 14:29:54 2025 +0000

    Parenthesize subexpressions consistently
---
 atr/admin/__init__.py          |  6 +++---
 atr/archives.py                |  4 ++--
 atr/db/interaction.py          |  2 +-
 atr/form.py                    | 10 +++++-----
 atr/get/announce.py            |  2 +-
 atr/get/checks.py              |  6 +++---
 atr/get/file.py                |  2 +-
 atr/get/finish.py              |  2 +-
 atr/get/projects.py            |  4 ++--
 atr/get/published.py           |  2 +-
 atr/get/sbom.py                | 16 ++++++++--------
 atr/jwtoken.py                 |  2 +-
 atr/manager.py                 |  2 +-
 atr/models/distribution.py     |  6 +++++-
 atr/post/draft.py              |  2 +-
 atr/post/resolve.py            |  8 ++++----
 atr/post/upload.py             |  2 +-
 atr/principal.py               |  2 +-
 atr/sbom/cli.py                |  2 +-
 atr/sbom/conformance.py        |  2 +-
 atr/sbom/models/licenses.py    |  4 ++--
 atr/sbom/osv.py                |  7 ++++---
 atr/sbom/tool.py               |  2 +-
 atr/sbom/utilities.py          |  6 +++---
 atr/server.py                  |  2 +-
 atr/shared/__init__.py         |  2 +-
 atr/shared/projects.py         |  2 +-
 atr/storage/writers/release.py |  2 +-
 atr/tabulate.py                |  6 +++---
 atr/tasks/checks/hashing.py    |  2 +-
 atr/tasks/sbom.py              |  4 ++--
 atr/util.py                    | 26 +++++++++++++-------------
 atr/validate.py                |  4 ++--
 33 files changed, 79 insertions(+), 74 deletions(-)

diff --git a/atr/admin/__init__.py b/atr/admin/__init__.py
index 56cac73..85010f4 100644
--- a/atr/admin/__init__.py
+++ b/atr/admin/__init__.py
@@ -403,7 +403,7 @@ async def delete_test_openpgp_keys_post(session: 
web.Committer) -> web.Response:
             delete_outcome = await wafc.keys.test_user_delete_all(test_uid)
             deleted_count = delete_outcome.result_or_raise()
 
-        suffix = "s" if deleted_count != 1 else ""
+        suffix = "s" if (deleted_count != 1) else ""
         await quart.flash(
             f"Successfully deleted {deleted_count} OpenPGP key{suffix} and 
their associated links for test user.",
             "success",
@@ -643,7 +643,7 @@ async def performance(session: web.Committer) -> str:
                 "median": statistics.median(total_times),
                 "min": min(total_times),
                 "max": max(total_times),
-                "stdev": statistics.stdev(total_times) if len(total_times) > 1 
else 0,
+                "stdev": statistics.stdev(total_times) if (len(total_times) > 
1) else 0,
             },
             "sync": {
                 "mean": statistics.mean(sync_times),
@@ -834,7 +834,7 @@ async def toggle_view_get(session: web.Committer) -> str:
 async def toggle_view_post(session: web.Committer) -> web.WerkzeugResponse:
     """Toggle between admin and user views."""
     app = asfquart.APP
-    if not hasattr(app, "app_id") or not isinstance(app.app_id, str):
+    if (not hasattr(app, "app_id")) or (not isinstance(app.app_id, str)):
         raise TypeError("Internal error: APP has no valid app_id")
 
     cookie_id = app.app_id
diff --git a/atr/archives.py b/atr/archives.py
index 0f96b0e..bea109f 100644
--- a/atr/archives.py
+++ b/atr/archives.py
@@ -188,7 +188,7 @@ def _archive_extract_safe_process_hardlink(member: 
tarfile.TarInfo, extract_dir:
 
     link_target = member.linkname or ""
     source_path = _safe_path(extract_dir, link_target)
-    if source_path is None or not os.path.exists(source_path):
+    if (source_path is None) or (not os.path.exists(source_path)):
         log.warning(f"Skipping hard link with invalid target: {member.name} -> 
{link_target}")
         return
 
@@ -283,7 +283,7 @@ def _zip_archive_extract_member(
     if member_basename.startswith("._"):
         return 0, extracted_paths
 
-    if member.isfile() and (total_extracted + member.size) > max_size:
+    if member.isfile() and ((total_extracted + member.size) > max_size):
         raise ExtractionError(
             f"Extraction would exceed maximum size limit of {max_size} bytes",
             {"max_size": max_size, "current_size": total_extracted, 
"file_size": member.size},
diff --git a/atr/db/interaction.py b/atr/db/interaction.py
index bd9dc7d..f8026f8 100644
--- a/atr/db/interaction.py
+++ b/atr/db/interaction.py
@@ -383,7 +383,7 @@ async def tasks_ongoing_revision(
         .where(
             sql.Task.project_name == project_name,
             sql.Task.version_name == version_name,
-            sql.Task.revision_number == (subquery if revision_number is None 
else revision_number),
+            sql.Task.revision_number == (subquery if (revision_number is None) 
else revision_number),
             sql.validate_instrumented_attribute(sql.Task.status).in_(
                 [sql.TaskStatus.QUEUED, sql.TaskStatus.ACTIVE],
             ),
diff --git a/atr/form.py b/atr/form.py
index 0f3dba0..78292bc 100644
--- a/atr/form.py
+++ b/atr/form.py
@@ -612,7 +612,7 @@ def _get_choices(field_info: pydantic.fields.FieldInfo) -> 
list[tuple[str, str]]
 
     if origin is list:
         args = get_args(annotation)
-        if args and get_origin(args[0]) is Literal:
+        if args and (get_origin(args[0]) is Literal):
             return [(v, v) for v in get_args(args[0])]
 
     # Check for plain enum types, e.g. when Pydantic unwraps form.Enum[T]
@@ -638,7 +638,7 @@ def _get_widget_classes(widget_type: Widget, has_errors: 
list[str] | None) -> st
 
 def _get_widget_type(field_info: pydantic.fields.FieldInfo) -> Widget:  # 
noqa: C901
     json_schema_extra = field_info.json_schema_extra or {}
-    if isinstance(json_schema_extra, dict) and "widget" in json_schema_extra:
+    if isinstance(json_schema_extra, dict) and ("widget" in json_schema_extra):
         widget_value = json_schema_extra["widget"]
         if isinstance(widget_value, str):
             try:
@@ -725,13 +725,13 @@ def _parse_dynamic_choices(
         if isinstance(default_value[0], tuple) and (len(default_value[0]) == 
2):
             # List of (value, label) tuples
             choices = default_value
-            selected_value = field_value if not isinstance(field_value, list) 
else None
+            selected_value = field_value if (not isinstance(field_value, 
list)) else None
             return choices, selected_value
         else:
             # List of simple values
             choices = [(val, val) for val in default_value]
             selected_value = (
-                field_value if not isinstance(field_value, list) else 
(default_value[0] if default_value else None)
+                field_value if (not isinstance(field_value, list)) else 
(default_value[0] if default_value else None)
             )
             return choices, selected_value
 
@@ -1023,4 +1023,4 @@ def _render_widget(  # noqa: C901
         error_div = htm.div(".invalid-feedback.d-block")[error_text]
         elements.append(error_div)
 
-    return htm.div[elements] if len(elements) > 1 else elements[0]
+    return htm.div[elements] if (len(elements) > 1) else elements[0]
diff --git a/atr/get/announce.py b/atr/get/announce.py
index cda0930..1ff7327 100644
--- a/atr/get/announce.py
+++ b/atr/get/announce.py
@@ -220,7 +220,7 @@ def _render_mailing_list_with_warning(choices: 
list[tuple[str, str]], default_va
 
 def _render_download_path_field(default_value: str, description: str) -> 
htm.Element:
     """Render the download path suffix field with custom help text."""
-    base_text = description.split(" plus this suffix")[0] if " plus this 
suffix" in description else description
+    base_text = description.split(" plus this suffix")[0] if (" plus this 
suffix" in description) else description
     return htm.div[
         htpy.input(
             "#download_path_suffix.form-control",
diff --git a/atr/get/checks.py b/atr/get/checks.py
index 0e0815f..f4f5dac 100644
--- a/atr/get/checks.py
+++ b/atr/get/checks.py
@@ -368,12 +368,12 @@ def _render_file_row(
         path_display = htpy.strong[htpy.code(".text-danger")[path_str]]
         pass_cell = (
             htpy.span(".text-success", style=num_style)[str(pass_count)]
-            if pass_count > 0
+            if (pass_count > 0)
             else htpy.span(".text-muted", style=num_style)["0"]
         )
         warn_cell = (
             htpy.span(".text-warning", style=num_style)[str(warn_count)]
-            if warn_count > 0
+            if (warn_count > 0)
             else htpy.span(".text-muted", style=num_style)["0"]
         )
         err_cell = htpy.span(".text-danger.fw-bold", 
style=num_style)[str(err_count)]
@@ -382,7 +382,7 @@ def _render_file_row(
         path_display = htpy.strong[htpy.code(".text-warning")[path_str]]
         pass_cell = (
             htpy.span(".text-success", style=num_style)[str(pass_count)]
-            if pass_count > 0
+            if (pass_count > 0)
             else htpy.span(".text-muted", style=num_style)["0"]
         )
         warn_cell = htpy.span(".text-warning.fw-bold", 
style=num_style)[str(warn_count)]
diff --git a/atr/get/file.py b/atr/get/file.py
index 85f7877..2018af9 100644
--- a/atr/get/file.py
+++ b/atr/get/file.py
@@ -172,7 +172,7 @@ async def selected_path(session: web.Committer, 
project_name: str, version_name:
 
 def _render_file_content(block: htm.Block, content: str, is_text: bool, 
is_truncated: bool, max_view_size: int) -> None:
     card = htm.Block(htm.div, classes=".card.mb-4")
-    card.div(".card-header")[htm.h3(".mb-0")["File content" + (" (Hexdump)" if 
not is_text else "")]]
+    card.div(".card-header")[htm.h3(".mb-0")["File content" + (" (Hexdump)" if 
(not is_text) else "")]]
 
     if is_text:
         
card.div(".card-body.p-0")[htm.pre(".bg-light.p-4.rounded-bottom.mb-0.text-break")[content]]
diff --git a/atr/get/finish.py b/atr/get/finish.py
index 63731a8..880dfe5 100644
--- a/atr/get/finish.py
+++ b/atr/get/finish.py
@@ -126,7 +126,7 @@ async def _deletable_choices(
                 # Disallow deletion of the root directory
                 continue
             d_full = latest_revision_dir / d_rel
-            if await aiofiles.os.path.isdir(d_full) and not await 
aiofiles.os.listdir(d_full):
+            if (await aiofiles.os.path.isdir(d_full)) and (not await 
aiofiles.os.listdir(d_full)):
                 empty_deletable_dirs.append(d_rel)
     return sorted([(str(p), str(p)) for p in empty_deletable_dirs])
 
diff --git a/atr/get/projects.py b/atr/get/projects.py
index f896b75..c1eb00b 100644
--- a/atr/get/projects.py
+++ b/atr/get/projects.py
@@ -162,7 +162,7 @@ async def view(session: web.Committer, name: str) -> 
web.WerkzeugResponse | str:
     title_row = htm.div(".row")[
         htm.div(".col-md")[htm.h1[project.display_name]],
         
htm.div(".col-sm-auto")[htm.span(".badge.text-bg-secondary")[project.status.value.lower()]]
-        if project.status.value.lower() != "active"
+        if (project.status.value.lower() != "active")
         else "",
     ]
     page.append(title_row)
@@ -233,7 +233,7 @@ def _render_categories_section(project: sql.Project) -> 
htm.Element:
                     ".btn-close.btn-close-white.ms-1.page-remove-tag", 
type="submit", aria_label=f"Remove {cat}"
                 ),
             ]
-            if cat not in registry.FORBIDDEN_PROJECT_CATEGORIES
+            if (cat not in registry.FORBIDDEN_PROJECT_CATEGORIES)
             else ""
         )
         badge = 
htm.div(".badge.bg-primary.d-inline-flex.align-items-center.px-2.py-1")[
diff --git a/atr/get/published.py b/atr/get/published.py
index ad5c959..eb5621f 100644
--- a/atr/get/published.py
+++ b/atr/get/published.py
@@ -56,7 +56,7 @@ async def _directory_listing(full_path: pathlib.Path, 
current_path: str) -> web.
 async def _directory_listing_pre(full_path: pathlib.Path, current_path: str, 
pre: htm.Block) -> None:
     if current_path:
         parent_path = pathlib.Path(current_path).parent
-        parent_url_path = str(parent_path) if str(parent_path) != "." else ""
+        parent_url_path = str(parent_path) if (str(parent_path) != ".") else ""
         if parent_url_path:
             pre.a(href=util.as_url(path, path=parent_url_path))["../"]
         else:
diff --git a/atr/get/sbom.py b/atr/get/sbom.py
index f2ea02c..d60ca1a 100644
--- a/atr/get/sbom.py
+++ b/atr/get/sbom.py
@@ -106,7 +106,7 @@ async def report(session: web.Committer, project: str, 
version: str, file_path:
             latest_augment = augment_tasks[0]
             augment_results: list[Any] = [t.result for t in augment_tasks]
             augmented_bom_versions = [
-                r.bom_version for r in augment_results if r is not None and 
r.bom_version is not None
+                r.bom_version for r in augment_results if (r is not None) and 
(r.bom_version is not None)
             ]
             if len(augmented_bom_versions) > 0:
                 last_augmented_bom = max(augmented_bom_versions)
@@ -160,7 +160,7 @@ def _outdated_tool_section(block: htm.Block, task_result: 
results.SBOMToolScore)
                             {result.available_version}."""
                     ]
             else:
-                if result.kind == "missing_metadata" or result.kind == 
"missing_timestamp":
+                if (result.kind == "missing_metadata") or (result.kind == 
"missing_timestamp"):
                     # These both return without checking any further tools as 
they prevent checking
                     block.p[
                         f"""There was a problem with the SBOM detected when 
trying to
@@ -257,13 +257,13 @@ def _augment_section(
         augments = [t.get("value", "") for t in task_result.atr_props if 
t.get("name", "") == "asf:atr:augment"]
     if latest_task is not None:
         result: Any = latest_task.result
-        if latest_task.status == sql.TaskStatus.ACTIVE or latest_task.status 
== sql.TaskStatus.QUEUED:
+        if (latest_task.status == sql.TaskStatus.ACTIVE) or 
(latest_task.status == sql.TaskStatus.QUEUED):
             block.p["This SBOM is currently being augmented by ATR."]
             return
         if latest_task.status == sql.TaskStatus.FAILED:
             block.p[f"ATR attempted to augment this SBOM but failed: 
{latest_task.error}"]
             return
-        if last_bom is not None and result.bom_version == last_bom and 
len(augments) != 0:
+        if (last_bom is not None) and (result.bom_version == last_bom) and 
(len(augments) != 0):
             block.p["This SBOM was augmented by ATR at revision ", 
htm.code[augments[-1]], "."]
             return
 
@@ -444,9 +444,9 @@ def _vulnerability_scan_find_completed_task(
 ) -> sql.Task | None:
     """Find the most recent completed OSV scan task for the given revision."""
     for task in osv_tasks:
-        if task.status == sql.TaskStatus.COMPLETED and (task.result is not 
None):
+        if (task.status == sql.TaskStatus.COMPLETED) and (task.result is not 
None):
             task_result = task.result
-            if isinstance(task_result, results.SBOMOSVScan) and 
task_result.revision_number == revision_number:
+            if isinstance(task_result, results.SBOMOSVScan) and 
(task_result.revision_number == revision_number):
                 return task
     return None
 
@@ -511,7 +511,7 @@ def _vulnerability_scan_results(
                     vulnerabilities=[
                         _cdx_to_osv(v)
                         for v in vulns
-                        if v.affects is not None and component in 
[a.get("ref") for a in v.affects]
+                        if (v.affects is not None) and (component in 
[a.get("ref") for a in v.affects])
                     ],
                 ),
             )
@@ -531,7 +531,7 @@ def _cdx_to_osv(cdx: osv.CdxVulnerabilityDetail) -> 
osv.VulnerabilityDetails:
         severity=score,
         database_specific={"severity": severity},
         references=[{"type": "WEB", "url": a.get("url", "")} for a in 
cdx.advisories]
-        if cdx.advisories is not None
+        if (cdx.advisories is not None)
         else [],
     )
 
diff --git a/atr/jwtoken.py b/atr/jwtoken.py
index 6b44cdc..1dc0d92 100644
--- a/atr/jwtoken.py
+++ b/atr/jwtoken.py
@@ -127,7 +127,7 @@ async def verify_github_oidc(token: str) -> dict[str, Any]:
 def _extract_bearer_token(request: quart.Request) -> str:
     header = request.headers.get("Authorization", "")
     scheme, _, token = header.partition(" ")
-    if scheme.lower() != "bearer" or not token:
+    if (scheme.lower() != "bearer") or (not token):
         raise base.ASFQuartException(
             "Authentication required. Please provide a valid Bearer token in 
the Authorization header", errorcode=401
         )
diff --git a/atr/manager.py b/atr/manager.py
index 984531b..37a6281 100644
--- a/atr/manager.py
+++ b/atr/manager.py
@@ -263,7 +263,7 @@ class WorkerManager:
         try:
             async with data.begin():
                 task = await data.task(pid=pid, 
status=sql.TaskStatus.ACTIVE).get()
-                if not task or not task.started:
+                if (not task) or (not task.started):
                     return False
 
                 task_duration = (datetime.datetime.now(datetime.UTC) - 
task.started).total_seconds()
diff --git a/atr/models/distribution.py b/atr/models/distribution.py
index 2e199c8..802ddde 100644
--- a/atr/models/distribution.py
+++ b/atr/models/distribution.py
@@ -101,7 +101,11 @@ class Data(schema.Lax):
     @pydantic.field_validator("owner_namespace", mode="before")
     @classmethod
     def empty_to_none(cls, v):
-        return None if v is None or (isinstance(v, str) and v.strip() == "") 
else v
+        if v is None:
+            return None
+        if isinstance(v, str) and (v.strip() == ""):
+            return None
+        return v
 
 
 class Metadata(schema.Strict):
diff --git a/atr/post/draft.py b/atr/post/draft.py
index 4d096b1..8ddefac 100644
--- a/atr/post/draft.py
+++ b/atr/post/draft.py
@@ -94,7 +94,7 @@ async def delete_file(
     if metadata_files_deleted:
         success_message += (
             f", and {metadata_files_deleted} associated metadata "
-            f"file{'' if metadata_files_deleted == 1 else 's'} deleted"
+            f"file{'' if (metadata_files_deleted == 1) else 's'} deleted"
         )
     return await session.redirect(
         get.compose.selected, success=success_message, 
project_name=project_name, version_name=version_name
diff --git a/atr/post/resolve.py b/atr/post/resolve.py
index 609f537..9df73d7 100644
--- a/atr/post/resolve.py
+++ b/atr/post/resolve.py
@@ -55,7 +55,7 @@ async def _submit(
         _release, voting_round, success_message, error_message = await 
wacm.vote.resolve(
             project_name,
             version_name,
-            "passed" if vote_result == "Passed" else "failed",
+            "passed" if (vote_result == "Passed") else "failed",
             session.fullname,
             email_body,
         )
@@ -144,9 +144,9 @@ async def _tabulate(session: web.Committer, project_name: 
str, version_name: str
     return await template.render(
         "resolve-tabulated.html",
         release=release,
-        tabulated_votes=details.votes if details is not None else {},
-        summary=details.summary if details is not None else {},
-        outcome=details.outcome if details is not None else "",
+        tabulated_votes=details.votes if (details is not None) else {},
+        summary=details.summary if (details is not None) else {},
+        outcome=details.outcome if (details is not None) else "",
         resolve_form=resolve_form,
         fetch_error=fetch_error,
         archive_url=archive_url,
diff --git a/atr/post/upload.py b/atr/post/upload.py
index 26cfb88..3a0505c 100644
--- a/atr/post/upload.py
+++ b/atr/post/upload.py
@@ -65,7 +65,7 @@ async def finalise(
         async with storage.write(session) as write:
             wacp = await write.as_project_committee_participant(project_name)
             number_of_files = len(staged_files)
-            plural = "s" if number_of_files != 1 else ""
+            plural = "s" if (number_of_files != 1) else ""
             description = f"Upload of {number_of_files} file{plural} through 
web interface"
 
             async with wacp.release.create_and_manage_revision(project_name, 
version_name, description) as creating:
diff --git a/atr/principal.py b/atr/principal.py
index 911dce1..a70f034 100644
--- a/atr/principal.py
+++ b/atr/principal.py
@@ -147,7 +147,7 @@ class Committer:
                 ldap_base=self.dn,
                 ldap_scope="BASE",
             )
-            if not (result and len(result) == 1):
+            if not (result and (len(result) == 1)):
                 raise CommitterError(f"User {self.user!r} not found in LDAP")
         except CommitterError:
             raise
diff --git a/atr/sbom/cli.py b/atr/sbom/cli.py
index b4dfe1a..512a93c 100644
--- a/atr/sbom/cli.py
+++ b/atr/sbom/cli.py
@@ -49,7 +49,7 @@ def command_license(bundle: models.bundle.Bundle) -> None:
             license_str = 
f"{error.license_expression}{scope_str}{unknown_suffix}"
             print(f"  - {name_str}: {license_str}")
         print()
-    if not warnings and not errors:
+    if (not warnings) and (not errors):
         print("All licenses are approved (Category A)")
 
 
diff --git a/atr/sbom/conformance.py b/atr/sbom/conformance.py
index ae39e1c..96b0f63 100644
--- a/atr/sbom/conformance.py
+++ b/atr/sbom/conformance.py
@@ -140,7 +140,7 @@ async def assemble_component_supplier(
         links = get_pointer(data, "/links") or []
         homepage = None
         for link in links:
-            if isinstance(link, dict) and link.get("label") == "HOMEPAGE":
+            if isinstance(link, dict) and (link.get("label") == "HOMEPAGE"):
                 homepage = link.get("url")
                 break
         if homepage:
diff --git a/atr/sbom/models/licenses.py b/atr/sbom/models/licenses.py
index d105006..18f23ed 100644
--- a/atr/sbom/models/licenses.py
+++ b/atr/sbom/models/licenses.py
@@ -49,6 +49,6 @@ class Issue(Strict):
         return value if isinstance(value, Category) else Category(value)
 
     def __str__(self):
-        type_str = "Component" if self.component_type is None else 
self.component_type
-        version_str = f"@{self.component_version}" if self.component_version 
!= "UNKNOWN" else ""
+        type_str = "Component" if (self.component_type is None) else 
self.component_type
+        version_str = f"@{self.component_version}" if (self.component_version 
!= "UNKNOWN") else ""
         return f"{type_str} {self.component_name}{version_str} declares 
license {self.license_expression}"
diff --git a/atr/sbom/osv.py b/atr/sbom/osv.py
index 01609ba..78ccc38 100644
--- a/atr/sbom/osv.py
+++ b/atr/sbom/osv.py
@@ -152,7 +152,8 @@ def _assemble_component_vulnerability(
         vulnerability["advisories"] = [
             {"url": r["url"]}
             for r in vuln.references
-            if (r.get("type", "") == "WEB" and "advisories" in r.get("url", 
"")) or r.get("type", "") == "ADVISORY"
+            if ((r.get("type", "") == "WEB") and ("advisories" in r.get("url", 
"")))
+            or (r.get("type", "") == "ADVISORY")
         ]
     patch_ops.append(
         models.patch.AddOp(
@@ -217,7 +218,7 @@ async def _fetch_vulnerability_details(
 def _get_source(vuln: models.osv.VulnerabilityDetails) -> dict[str, str]:
     db = vuln.id.split("-")[0]
     web_refs = list(filter(lambda v: v.get("type", "") == "WEB", 
vuln.references)) if vuln.references else []
-    first_ref = web_refs[0] if len(web_refs) > 0 else None
+    first_ref = web_refs[0] if (len(web_refs) > 0) else None
 
     name = _SOURCE_DATABASE_NAMES.get(db, "Unknown Database")
     source = {"name": name}
@@ -237,7 +238,7 @@ async def _paginate_query(
     page = 0
     while True:
         page += 1
-        if _DEBUG and page > 1:
+        if _DEBUG and (page > 1):
             print(f"[DEBUG] Paginating query (page {page})")
         results = await _fetch_vulnerabilities_for_batch(session, 
[current_query])
         if not results:
diff --git a/atr/sbom/tool.py b/atr/sbom/tool.py
index febf733..b7f84ae 100644
--- a/atr/sbom/tool.py
+++ b/atr/sbom/tool.py
@@ -86,7 +86,7 @@ def outdated_version_core(
         return None
     expected_version_comparable = version_parse(expected_version)
     version_comparable = version_parse(version)
-    if expected_version_comparable is None or version_comparable is None:
+    if (expected_version_comparable is None) or (version_comparable is None):
         # Couldn't parse the version
         return None
     # If the version used is less than the version available
diff --git a/atr/sbom/utilities.py b/atr/sbom/utilities.py
index fa91930..900bfb5 100644
--- a/atr/sbom/utilities.py
+++ b/atr/sbom/utilities.py
@@ -144,7 +144,7 @@ def cdx_severity_to_osv(severity: list[dict[str, str | 
float]]) -> tuple[str | N
 
 
 def _extract_cdx_score(type: str, score_str: str) -> dict[str, str | float]:
-    if "CVSS" in score_str or "CVSS" in type:
+    if ("CVSS" in score_str) or ("CVSS" in type):
         components = re.match(r"CVSS:(?P<version>\d+\.?\d*)/.+", score_str)
         parsed = None
         vector = score_str
@@ -153,9 +153,9 @@ def _extract_cdx_score(type: str, score_str: str) -> 
dict[str, str | float]:
             parsed = cvss.CVSS2(vector)
         else:
             version = components.group("version")
-            if "3" in version or "V3" in type:
+            if ("3" in version) or ("V3" in type):
                 parsed = cvss.CVSS3(vector)
-            elif "4" in version or "V4" in type:
+            elif ("4" in version) or ("V4" in type):
                 parsed = cvss.CVSS4(vector)
         if parsed is not None:
             # Pull a different score depending on which sections are filled out
diff --git a/atr/server.py b/atr/server.py
index 1290ea8..233cf4b 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -351,7 +351,7 @@ def _app_setup_logging(app: base.QuartApp, config_mode: 
config.Mode, app_config:
     # Only log in the worker process
     @app.before_serving
     async def log_debug_info() -> None:
-        if config_mode == config.Mode.Debug or config_mode == 
config.Mode.Profiling:
+        if (config_mode == config.Mode.Debug) or (config_mode == 
config.Mode.Profiling):
             log.info(f"DEBUG        = {config_mode == config.Mode.Debug}")
             log.info(f"ENVIRONMENT  = {config_mode.value}")
             log.info(f"STATE_DIR    = {app_config.STATE_DIR}")
diff --git a/atr/shared/__init__.py b/atr/shared/__init__.py
index b7d6192..dffeb9a 100644
--- a/atr/shared/__init__.py
+++ b/atr/shared/__init__.py
@@ -206,7 +206,7 @@ def _warnings_from_vote_result(vote_task: sql.Task | None) 
-> list[str]:
     # But we'd still need to do some of this parsing and validation
     # We should probably rethink how to send data through tasks
 
-    if not vote_task or (not vote_task.result):
+    if (not vote_task) or (not vote_task.result):
         return ["No vote task result found."]
 
     vote_task_result = vote_task.result
diff --git a/atr/shared/projects.py b/atr/shared/projects.py
index fe5e969..9619bca 100644
--- a/atr/shared/projects.py
+++ b/atr/shared/projects.py
@@ -202,7 +202,7 @@ class VotePolicyForm(form.Form):
                     raise ValueError("GitHub workflow paths must start with 
'.github/workflows/'.")
 
         min_hours = self.min_hours
-        if min_hours != 0 and (min_hours < 72 or min_hours > 144):
+        if (min_hours != 0) and ((min_hours < 72) or (min_hours > 144)):
             raise ValueError("Minimum voting period must be 0 or between 72 
and 144 hours inclusive.")
 
         return self
diff --git a/atr/storage/writers/release.py b/atr/storage/writers/release.py
index 88b2b82..840946b 100644
--- a/atr/storage/writers/release.py
+++ b/atr/storage/writers/release.py
@@ -433,7 +433,7 @@ class CommitteeParticipant(FoundationCommitter):
     ) -> int:
         """Process and save the uploaded files into a new draft revision."""
         number_of_files = len(files)
-        description = f"Upload of {number_of_files} file{'' if number_of_files 
== 1 else 's'} through web interface"
+        description = f"Upload of {number_of_files} file{'' if 
(number_of_files == 1) else 's'} through web interface"
         async with self.create_and_manage_revision(project_name, version_name, 
description) as creating:
             # Save each uploaded file to the new revision directory
             for file in files:
diff --git a/atr/tabulate.py b/atr/tabulate.py
index e2fb906..0ed64ca 100644
--- a/atr/tabulate.py
+++ b/atr/tabulate.py
@@ -227,10 +227,10 @@ def _vote_castings(body: str) -> 
list[tuple[models.tabulate.Vote, str]]:
         if _vote_break(line):
             break
 
-        plus_one = line.startswith("+1") or " +1" in line
-        minus_one = line.startswith("-1") or " -1" in line
+        plus_one = line.startswith("+1") or (" +1" in line)
+        minus_one = line.startswith("-1") or (" -1" in line)
         # We must be more stringent about zero votes, can't just check for "0" 
in line
-        zero = line in {"0", "-0", "+0"} or line.startswith("0 ") or 
line.startswith("+0 ") or line.startswith("-0 ")
+        zero = (line in {"0", "-0", "+0"}) or line.startswith("0 ") or 
line.startswith("+0 ") or line.startswith("-0 ")
         if (plus_one and minus_one) or (plus_one and zero) or (minus_one and 
zero):
             # Confusing result
             continue
diff --git a/atr/tasks/checks/hashing.py b/atr/tasks/checks/hashing.py
index d04458b..b7cb7c6 100644
--- a/atr/tasks/checks/hashing.py
+++ b/atr/tasks/checks/hashing.py
@@ -48,7 +48,7 @@ async def check(args: checks.FunctionArguments) -> 
results.Results | None:
         f"Checking hash ({algorithm}) for {artifact_abs_path} against 
{hash_abs_path} (rel: {args.primary_rel_path})"
     )
 
-    hash_func = hashlib.sha256 if algorithm == "sha256" else hashlib.sha512
+    hash_func = hashlib.sha256 if (algorithm == "sha256") else hashlib.sha512
     hash_obj = hash_func()
     try:
         async with aiofiles.open(artifact_abs_path, mode="rb") as f:
diff --git a/atr/tasks/sbom.py b/atr/tasks/sbom.py
index 31598dc..46ee194 100644
--- a/atr/tasks/sbom.py
+++ b/atr/tasks/sbom.py
@@ -63,7 +63,7 @@ class SBOMScoringError(Exception):
 
     def __init__(self, msg: str, context: dict[str, Any] | None = None) -> 
None:
         super().__init__(msg)
-        self.context = context if context is not None else {}
+        self.context = context if (context is not None) else {}
 
 
 class FileArgs(schema.Strict):
@@ -107,7 +107,7 @@ async def augment(args: FileArgs) -> results.Results | None:
 
     return results.SBOMAugment(
         kind="sbom_augment",
-        path=(new_full_path if new_full_path is not None else full_path),
+        path=(new_full_path if (new_full_path is not None) else full_path),
         bom_version=new_version,
     )
 
diff --git a/atr/util.py b/atr/util.py
index e3fbdf0..42ebea8 100644
--- a/atr/util.py
+++ b/atr/util.py
@@ -419,26 +419,26 @@ def format_permissions(mode: int) -> str:
         perms = "?"
 
     # Owner permissions
-    perms += "r" if mode & 0o400 else "-"
-    perms += "w" if mode & 0o200 else "-"
-    perms += "x" if mode & 0o100 else "-"
+    perms += "r" if (mode & 0o400) else "-"
+    perms += "w" if (mode & 0o200) else "-"
+    perms += "x" if (mode & 0o100) else "-"
 
     # Group permissions
-    perms += "r" if mode & 0o040 else "-"
-    perms += "w" if mode & 0o020 else "-"
-    perms += "x" if mode & 0o010 else "-"
+    perms += "r" if (mode & 0o040) else "-"
+    perms += "w" if (mode & 0o020) else "-"
+    perms += "x" if (mode & 0o010) else "-"
 
     # Others permissions
-    perms += "r" if mode & 0o004 else "-"
-    perms += "w" if mode & 0o002 else "-"
-    perms += "x" if mode & 0o001 else "-"
+    perms += "r" if (mode & 0o004) else "-"
+    perms += "w" if (mode & 0o002) else "-"
+    perms += "x" if (mode & 0o001) else "-"
 
     return perms
 
 
 async def get_asf_id_or_die() -> str:
     web_session = await session.read()
-    if web_session is None or web_session.uid is None:
+    if (web_session is None) or (web_session.uid is None):
         raise base.ASFQuartException("Not authenticated", errorcode=401)
     return web_session.uid
 
@@ -541,7 +541,7 @@ def is_user_viewing_as_admin(uid: str | None) -> bool:
 
     try:
         app = asfquart.APP
-        if not hasattr(app, "app_id") or not isinstance(app.app_id, str):
+        if (not hasattr(app, "app_id")) or (not isinstance(app.app_id, str)):
             log.error("Cannot get valid app_id to read session for admin view 
check")
             return True
 
@@ -904,7 +904,7 @@ async def thread_messages(
     messages: list[dict[str, Any]] = []
 
     async for url, status, content in get_urls_as_completed(email_urls):
-        if status != 200 or not content:
+        if (status != 200) or (not content):
             log.warning(f"Failed to fetch email data from {url}: {status}")
             continue
         try:
@@ -1048,7 +1048,7 @@ def _generate_hexdump(data: bytes) -> str:
         hex_part = binascii.hexlify(chunk).decode("ascii")
         hex_part = hex_part.ljust(32)
         hex_part_spaced = " ".join(hex_part[j : j + 2] for j in range(0, 
len(hex_part), 2))
-        ascii_part = "".join(chr(b) if 32 <= b < 127 else "." for b in chunk)
+        ascii_part = "".join(chr(b) if (32 <= b < 127) else "." for b in chunk)
         line_num = f"{i:08x}"
         hex_lines.append(f"{line_num}  {hex_part_spaced}  |{ascii_part}|")
     return "\n".join(hex_lines)
diff --git a/atr/validate.py b/atr/validate.py
index a230109..1b03b20 100644
--- a/atr/validate.py
+++ b/atr/validate.py
@@ -93,7 +93,7 @@ def committee_full_name(c: sql.Committee) -> Divergences:
     )
 
     def trimmed(fn: str | None) -> bool:
-        return False if fn is None else (fn == fn.strip())
+        return False if (fn is None) else (fn == fn.strip())
 
     yield from divergences_predicate(
         trimmed,
@@ -102,7 +102,7 @@ def committee_full_name(c: sql.Committee) -> Divergences:
     )
 
     def not_prefixed(fn: str | None) -> bool:
-        return False if fn is None else (not fn.startswith("Apache "))
+        return False if (fn is None) else (not fn.startswith("Apache "))
 
     yield from divergences_predicate(
         not_prefixed,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to