Skip to content

style(python): tidy builder-code CBOR helpers - #36

Draft
PhilBot402 wants to merge 2 commits into
mainfrom
philbotpython-style-cleanup-8965
Draft

PhilBot402 wants to merge 2 commits into
mainfrom
philbotpython-style-cleanup-8965

Conversation

@PhilBot402

Copy link
Copy Markdown
Owner

Description

Style-only cleanup of the Python builder-code CBOR helpers added in x402-foundation#3723. Encoding and parsing behavior is unchanged.

_CborCursor.read_argument called peek_major and ignored the return value, using it only as an end-of-buffer check. Integer metadata now goes straight to _encode_major_type, which already rejects values outside uint64 with the same ValueError. The top-level key dispatch is a flat if/elif, and an empty metadata dict is passed as m=metadata or None instead of through a one-use local.

No changelog fragment: this is not user-facing.

Tests

From python/x402/:

  • uvx ruff format and uvx ruff check on the touched modules
  • uv run pytest for the builder-code unit tests
  • uv run mypy on the touched modules

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
  • I added a changelog fragment for user-facing changes (docs-only changes can skip)

AI disclosure: automated by @phdargen. Use your own judgement

Open in Web Open in Cursor 

PhilBot402 and others added 2 commits October 7, 2026 16:27
…#3723)

* feat(python): add builder-code settlement metadata m

Port the facilitator-authored ERC-8021 Schema 2 field from the TypeScript and Go SDKs. Python now encodes and parses m, emits a suffix from metadata alone, ignores client-supplied m, and rejects CBOR larger than 65,535 bytes.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* chore(python): name the builder-code changelog fragment

Point the towncrier fragment at the upstream pull request.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
The settlement-metadata parser checked the buffer by calling peek_major and ignoring its result, and integer encoding repeated a range check that the major-type encoder already performs.

Co-authored-by: phdargen <29732335+phdargen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant