***v36 #36
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "mitch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
🤖 drep AI Code Review
The PR extracts inline Python from the CI config into a well-structured standalone script (
ci/add-ai-reviewed-label.py). This is a positive change for maintainability. The new script follows good practices: type hints, error handling, environment variable validation, timeouts, and clear constants. However, there are a few type safety concerns where the code assumes specific response types (dict vs list) from the genericapi_requestfunction. Adding runtime type checks or narrowing the return type per endpoint would improve robustness. Theindex.phpchange is just a version bump. Overall, a solid improvement with minor type-safety warnings to address.Recommendation: ✅ Approve
Concerns:
Generated by drep using nvidia/nemotron-3-ultra-550b-a55b:free
Inline review comment generated by drep.
@ -0,0 +27,4 @@body = Noneif data is not None:headers["Content-Type"] = "application/json"body = json.dumps(data).encode()💡 SUGGESTION: The return type
dict | listis too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.Suggested fix:
@ -0,0 +47,4 @@token = require_env("GITEA_TOKEN")owner = require_env("CI_REPO_OWNER")repo = require_env("CI_REPO_NAME")pr = require_env("CI_COMMIT_PULL_REQUEST")⚠️ WARNING: The
issuevariable is assumed to be a dict, butapi_requestcan return a list. If the API returns a list (unlikely for/issues/{pr}but possible on error), this will fail with AttributeError.Suggested fix:
@ -0,0 +51,4 @@base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"issue = api_request(token, "GET", f"{base}/issues/{pr}")labels_on_pr = issue.get("labels", [])⚠️ WARNING: Same issue here -
repo_labelsis assumed to be a list butapi_requestreturnsdict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.Suggested fix:
@ -0,0 +59,4 @@repo_labels = api_request(token, "GET", f"{base}/labels")label_id = next((label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),None,💡 SUGGESTION: The
createdvariable assumes the response is a dict with an 'id' key. Add validation for robustness.Suggested fix:
@ -0,0 +65,4 @@created = api_request(token,"POST",f"{base}/labels",ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though
sys.exit(0)is implicit.Suggested fix:
Inline review comment generated by drep.
@ -0,0 +27,4 @@body = Noneif data is not None:headers["Content-Type"] = "application/json"body = json.dumps(data).encode()💡 SUGGESTION: The return type
dict | listis too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.Suggested fix:
@ -0,0 +47,4 @@token = require_env("GITEA_TOKEN")owner = require_env("CI_REPO_OWNER")repo = require_env("CI_REPO_NAME")pr = require_env("CI_COMMIT_PULL_REQUEST")⚠️ WARNING: The
issuevariable is assumed to be a dict, butapi_requestcan return a list. If the API returns a list (unlikely for/issues/{pr}but possible on error), this will fail with AttributeError.Suggested fix:
@ -0,0 +51,4 @@base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"issue = api_request(token, "GET", f"{base}/issues/{pr}")labels_on_pr = issue.get("labels", [])⚠️ WARNING: Same issue here -
repo_labelsis assumed to be a list butapi_requestreturnsdict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.Suggested fix:
@ -0,0 +59,4 @@repo_labels = api_request(token, "GET", f"{base}/labels")label_id = next((label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),None,💡 SUGGESTION: The
createdvariable assumes the response is a dict with an 'id' key. Add validation for robustness.Suggested fix:
@ -0,0 +65,4 @@created = api_request(token,"POST",f"{base}/labels",ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though
sys.exit(0)is implicit.Suggested fix:
Inline review comment generated by drep.
@ -0,0 +27,4 @@body = Noneif data is not None:headers["Content-Type"] = "application/json"body = json.dumps(data).encode()💡 SUGGESTION: The return type
dict | listis too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.Suggested fix:
@ -0,0 +47,4 @@token = require_env("GITEA_TOKEN")owner = require_env("CI_REPO_OWNER")repo = require_env("CI_REPO_NAME")pr = require_env("CI_COMMIT_PULL_REQUEST")⚠️ WARNING: The
issuevariable is assumed to be a dict, butapi_requestcan return a list. If the API returns a list (unlikely for/issues/{pr}but possible on error), this will fail with AttributeError.Suggested fix:
@ -0,0 +51,4 @@base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"issue = api_request(token, "GET", f"{base}/issues/{pr}")labels_on_pr = issue.get("labels", [])⚠️ WARNING: Same issue here -
repo_labelsis assumed to be a list butapi_requestreturnsdict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.Suggested fix:
@ -0,0 +59,4 @@repo_labels = api_request(token, "GET", f"{base}/labels")label_id = next((label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),None,💡 SUGGESTION: The
createdvariable assumes the response is a dict with an 'id' key. Add validation for robustness.Suggested fix:
@ -0,0 +65,4 @@created = api_request(token,"POST",f"{base}/labels",ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though
sys.exit(0)is implicit.Suggested fix:
Inline review comment generated by drep.
@ -0,0 +27,4 @@body = Noneif data is not None:headers["Content-Type"] = "application/json"body = json.dumps(data).encode()💡 SUGGESTION: The return type
dict | listis too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.Suggested fix:
@ -0,0 +47,4 @@token = require_env("GITEA_TOKEN")owner = require_env("CI_REPO_OWNER")repo = require_env("CI_REPO_NAME")pr = require_env("CI_COMMIT_PULL_REQUEST")⚠️ WARNING: The
issuevariable is assumed to be a dict, butapi_requestcan return a list. If the API returns a list (unlikely for/issues/{pr}but possible on error), this will fail with AttributeError.Suggested fix:
@ -0,0 +51,4 @@base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"issue = api_request(token, "GET", f"{base}/issues/{pr}")labels_on_pr = issue.get("labels", [])⚠️ WARNING: Same issue here -
repo_labelsis assumed to be a list butapi_requestreturnsdict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.Suggested fix:
@ -0,0 +59,4 @@repo_labels = api_request(token, "GET", f"{base}/labels")label_id = next((label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),None,💡 SUGGESTION: The
createdvariable assumes the response is a dict with an 'id' key. Add validation for robustness.Suggested fix:
@ -0,0 +65,4 @@created = api_request(token,"POST",f"{base}/labels",ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though
sys.exit(0)is implicit.Suggested fix:
Inline review comment generated by drep.
@ -0,0 +27,4 @@body = Noneif data is not None:headers["Content-Type"] = "application/json"body = json.dumps(data).encode()💡 SUGGESTION: The return type
dict | listis too broad. The Gitea API returns different types for different endpoints. Consider using separate functions or a more precise return type per endpoint, or at minimum add a comment documenting expected return types per endpoint.Suggested fix:
@ -0,0 +47,4 @@token = require_env("GITEA_TOKEN")owner = require_env("CI_REPO_OWNER")repo = require_env("CI_REPO_NAME")pr = require_env("CI_COMMIT_PULL_REQUEST")⚠️ WARNING: The
issuevariable is assumed to be a dict, butapi_requestcan return a list. If the API returns a list (unlikely for/issues/{pr}but possible on error), this will fail with AttributeError.Suggested fix:
@ -0,0 +51,4 @@base = f"{GITEA_URL}/api/v1/repos/{owner}/{repo}"issue = api_request(token, "GET", f"{base}/issues/{pr}")labels_on_pr = issue.get("labels", [])⚠️ WARNING: Same issue here -
repo_labelsis assumed to be a list butapi_requestreturnsdict | list. If the API returns a dict (e.g., error response wrapped differently), the generator expression will fail.Suggested fix:
@ -0,0 +59,4 @@repo_labels = api_request(token, "GET", f"{base}/labels")label_id = next((label["id"] for label in repo_labels if label.get("name") == LABEL_NAME),None,💡 SUGGESTION: The
createdvariable assumes the response is a dict with an 'id' key. Add validation for robustness.Suggested fix:
@ -0,0 +65,4 @@created = api_request(token,"POST",f"{base}/labels",ℹ️ INFO: Consider adding a success exit code explicitly for clarity, though
sys.exit(0)is implicit.Suggested fix: