fix: replace mutable default arguments with None sentinels across backend - #2252
Open
harshadkhetpal wants to merge 2 commits into
Open
fix: replace mutable default arguments with None sentinels across backend#2252harshadkhetpal wants to merge 2 commits into
harshadkhetpal wants to merge 2 commits into
Conversation
…kend Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
Contributor
|
| Filename | Overview |
|---|---|
| backend/api_v2/deployment_helper.py | Replaces the shared tag-name list default with an optional sentinel and per-call list. |
| backend/workflow_manager/endpoint_v2/queue_utils.py | Replaces shared connector-settings defaults in both queue factory methods. |
| backend/workflow_manager/endpoint_v2/source.py | Replaces the shared file-hash default used during source enumeration. |
| backend/workflow_manager/workflow_v2/dto.py | Replaces the shared metadata-key removal list with a per-call list. |
| backend/workflow_manager/workflow_v2/views.py | Normalizes the optional file-hash mapping at the workflow view boundary. |
| backend/workflow_manager/workflow_v2/workflow_helper.py | Applies optional file-hash sentinels consistently across workflow execution entry points. |
Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile
for more information, see https://pre-commit.ci
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Replaces the nine mutable default arguments in
backend/(ruff B006) with the standardNonesentinel + normalization pattern. Python evaluates defaults once at import time, so= {}/= []defaults are shared across every call — a latent cross-request state-leak hazard in long-lived Django workers:api_v2/deployment_helper.py—tag_names: list[str] = []workflow_manager/endpoint_v2/queue_utils.py—connector_settings: dict = {}×2workflow_manager/endpoint_v2/source.py—file_hashes: dict[str, FileHash] = {}workflow_manager/workflow_v2/dto.py—keys_to_remove: list[str] = []workflow_manager/workflow_v2/views.py—hash_values_of_files: dict[str, FileHash] = {}workflow_manager/workflow_v2/workflow_helper.py— same parameter ×3 (run_workflow, pipeline execution, execution-action dispatch)Each signature becomes
... | None = Nonewith aparam = param or {}(or[]) normalization as the first statement after the docstring, so all existing callers — including those passingNoneexplicitly — get identical behavior.Testing
python -m py_compilepasses on all seven files;ruff check --select B006on the touched paths goes from 9 errors to clean.🤖 Generated with Claude Code