Repository navigation
refactor: hoist per-call status/field set literals to module-level frozenset constants - #733
Open
PratikDhanave wants to merge 1 commit into
Open
PratikDhanave wants to merge 1 commit into
PratikDhanave wants to merge 1 commit into
Conversation
…ozenset constants Two helpers rebuilt a small, constant set literal on every call. Hoist each to a module-level frozenset constant and reference it instead: - policy/client.py: the GENERATE_FAILED/DELETE_FAILED terminal statuses in the policy-generation wait (now _GENERATION_FAILED_STATUSES). - payments/manager.py: the required-field sets for payment-required request validation and X.402 payload validation (now _PAYMENT_REQUIRED_FIELDS and _X402_PAYLOAD_REQUIRED_FIELDS). Pure readability/allocation refactor. Members and membership semantics are unchanged; behavior is identical.
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
PratikDhanave
requested a deployment
to
manual-approval
November 4, 2026 17:26 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
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.
Description
Small, behavior-preserving readability refactor. Not a bug fix — the current code is functionally correct. A few helpers construct the same constant set literal on every call; this hoists each to a module-level
frozensetconstant and references it instead.Changes
src/bedrock_agentcore/policy/client.py—start_policy_generationbuilt{"GENERATE_FAILED", "DELETE_FAILED"}locally for each call. Hoisted to a module-level_GENERATION_FAILED_STATUSESconstant (sits next to the existing_FAILED_STATUSES).src/bedrock_agentcore/payments/manager.py— two validation helpers rebuilt required-field sets per call. Hoisted to module-level_PAYMENT_REQUIRED_FIELDS({"statusCode", "headers", "body"}) and_X402_PAYLOAD_REQUIRED_FIELDS({"x402Version", "accepts"}).Rationale
Behavior
Members and membership semantics are unchanged. The constants are
frozensets (immutable); set-difference andsorted(...)over them produce identical results to the previoussetliterals, so all call sites behave exactly as before.Verification
ruff checkandruff format --checkon both files: clean.pytestfor the covering suites (tests/unit/policy/test_policy_engine_client.py,tests/bedrock_agentcore/payments/test_payment_manager.py,tests/bedrock_agentcore/payments/test_mpp_manager.py): 189 passed.