This is an automated email from the ASF dual-hosted git repository.
tn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-atr-experiments.git
The following commit(s) were added to refs/heads/main by this push:
new 07767b5 enable some more sane ruff checks
07767b5 is described below
commit 07767b55f49cdf1d55427f65eac8b9b5a23fabad
Author: Thomas Neidhart <[email protected]>
AuthorDate: Mon Feb 17 22:31:13 2025 +0100
enable some more sane ruff checks
---
atr/blueprints/secret/__init__.py | 5 ++---
atr/blueprints/secret/secret.py | 7 ++++---
atr/config.py | 20 +++++++++++---------
atr/routes.py | 13 ++++++-------
pyproject.toml | 13 ++++++++++++-
5 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/atr/blueprints/secret/__init__.py
b/atr/blueprints/secret/__init__.py
index dfd4942..c82efc1 100644
--- a/atr/blueprints/secret/__init__.py
+++ b/atr/blueprints/secret/__init__.py
@@ -17,8 +17,7 @@
from quart import Blueprint
-from asfquart.auth import Requirements as R
-from asfquart.auth import require
+from asfquart.auth import Requirements, require
from asfquart.base import ASFQuartException
from asfquart.session import read as session_read
from atr.util import get_admin_users
@@ -28,7 +27,7 @@ blueprint = Blueprint("secret_blueprint", __name__,
url_prefix="/secret")
@blueprint.before_request
async def before_request_func() -> None:
- @require(R.committer)
+ @require(Requirements.committer)
async def check_logged_in() -> None:
session = await session_read()
if session is None:
diff --git a/atr/blueprints/secret/secret.py b/atr/blueprints/secret/secret.py
index 7ec78c5..c6d5bcf 100644
--- a/atr/blueprints/secret/secret.py
+++ b/atr/blueprints/secret/secret.py
@@ -37,6 +37,8 @@ from atr.db.service import get_pmcs
from . import blueprint
+_WHIMSY_COMMITTEE_URL = "https://whimsy.apache.org/public/committee-info.json"
+
@blueprint.route("/data")
@blueprint.route("/data/<model>")
@@ -90,14 +92,13 @@ async def secret_pmcs_update() -> str:
if request.method == "POST":
# Fetch committee-info.json from Whimsy
- WHIMSY_URL = "https://whimsy.apache.org/public/committee-info.json"
async with httpx.AsyncClient() as client:
try:
- response = await client.get(WHIMSY_URL)
+ response = await client.get(_WHIMSY_COMMITTEE_URL)
response.raise_for_status()
data = response.json()
except (httpx.RequestError, json.JSONDecodeError) as e:
- raise ASFQuartException(f"Failed to fetch committee data:
{str(e)}", errorcode=500)
+ raise ASFQuartException(f"Failed to fetch committee data:
{e!s}", errorcode=500)
committees = data.get("committees", {})
updated_count = 0
diff --git a/atr/config.py b/atr/config.py
index f2154ec..7a3c11d 100644
--- a/atr/config.py
+++ b/atr/config.py
@@ -33,15 +33,17 @@ class AppConfig:
# Use aiosqlite for async SQLite access
SQLITE_URL = config("SQLITE_URL", default="sqlite+aiosqlite:///./atr.db")
- ADMIN_USERS = {
- "cwells",
- "fluxo",
- "gmcdonald",
- "humbedooh",
- "sbp",
- "tn",
- "wave",
- }
+ ADMIN_USERS = frozenset(
+ {
+ "cwells",
+ "fluxo",
+ "gmcdonald",
+ "humbedooh",
+ "sbp",
+ "tn",
+ "wave",
+ }
+ )
class ProductionConfig(AppConfig):
diff --git a/atr/routes.py b/atr/routes.py
index 0a77fb3..cc2fbf2 100644
--- a/atr/routes.py
+++ b/atr/routes.py
@@ -40,8 +40,7 @@ from sqlmodel import select
from werkzeug.datastructures import FileStorage
from asfquart import APP
-from asfquart.auth import Requirements as R
-from asfquart.auth import require
+from asfquart.auth import Requirements, require
from asfquart.base import ASFQuartException
from asfquart.session import ClientSession
from asfquart.session import read as session_read
@@ -166,7 +165,7 @@ async def ephemeral_gpg_home():
@APP.route("/add-release-candidate", methods=["GET", "POST"])
-@require(R.committer)
+@require(Requirements.committer)
async def root_add_release_candidate() -> str:
"""Add a release candidate to the database."""
session = await session_read()
@@ -187,7 +186,7 @@ async def root_add_release_candidate() -> str:
@APP.route("/release/signatures/verify/<release_key>")
-@require(R.committer)
+@require(Requirements.committer)
async def root_release_signatures_verify(release_key: str) -> str:
"""Verify the GPG signatures for all packages in a release candidate."""
session = await session_read()
@@ -315,7 +314,7 @@ async def root_pmc_list() -> list[dict]:
@APP.route("/user/keys/add", methods=["GET", "POST"])
-@require(R.committer)
+@require(Requirements.committer)
async def root_user_keys_add() -> str:
"""Add a new GPG key to the user's account."""
session = await session_read()
@@ -350,7 +349,7 @@ async def root_user_keys_add() -> str:
@APP.route("/user/keys/delete")
-@require(R.committer)
+@require(Requirements.committer)
async def root_user_keys_delete() -> str:
"""Debug endpoint to delete all of a user's keys."""
session = await session_read()
@@ -374,7 +373,7 @@ async def root_user_keys_delete() -> str:
@APP.route("/user/uploads")
-@require(R.committer)
+@require(Requirements.committer)
async def root_user_uploads() -> str:
"""Show all release candidates uploaded by the current user."""
session = await session_read()
diff --git a/pyproject.toml b/pyproject.toml
index 1161586..4b46c3e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -76,7 +76,18 @@ executionEnvironments = [
]
[tool.ruff]
-lint.select = ["I", "E", "W", "F", "C90", "UP"]
+lint.select = [
+ "I", # isort
+ "E",
+ "W",
+ "F",
+ "N", # pep8-naming
+ "RUF", # ruff-checks
+ "C90",
+ "TID", # flake8-tidy-imports
+ "TCH", # flake8-type-checking
+ "UP" # pyupgrade
+]
lint.ignore = []
line-length = 120
exclude = ["asfquart"]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]