Skip to content

fix(sdk-generator): emit ruff-clean Python for SSE streams (UP028/UP007/E712) - #51

Merged
calvin-archastro merged 1 commit into
mainfrom
fix/python-stream-ruff
Jun 30, 2026
Merged

fix(sdk-generator): emit ruff-clean Python for SSE streams (UP028/UP007/E712)#51
calvin-archastro merged 1 commit into
mainfrom
fix/python-stream-ruff

Conversation

@calvin-archastro

Copy link
Copy Markdown
Contributor

What changed

The archastro-python auto-regenerate PR fails ruff check on three generated patterns that ruff can't auto-fix (unsafe fixes / no fix), so they survive the regen's ruff --fix and break CI:

Rule Where Was Now
UP028 sync stream() for event in stream_sse_sync(...): yield event yield from stream_sse_sync(...)
UP007 SSE event union Union[A, B, …] A | B | …
E712 channel contract test == True / == False is True / is False

Optional[X] field annotations are intentionally left for ruff's pyupgrade to rewrite (the existing design — see the test comment) and are unchanged.

Scope / risk

Generator-only (Python + Python-contract-test emitters). No runtime behavior change — yield from is equivalent to the delegating loop; the union/annotation changes are type-equivalent; is True is the lint-clean form of the same assertion.

Testing

  • Generator suite 300 pass (updated the one streaming test that asserted Union[).
  • Regenerated the full Python SDK + contract tests and ran the regen's ruff sequence (ruff check --fix + ruff format + ruff check) against archastro-python's config → All checks passed.

Follow-up

Needs a generator republish for the archastro-python auto-regen (PR #30) to pick it up; re-running the regenerate workflow after that produces ruff-clean output.

…07/E712)

The Python auto-regen failed `ruff check` on three patterns ruff can't
auto-fix (unsafe / no fix), so they survived the regen's `ruff --fix`:

- UP028: the sync stream() used `for event in stream_sse_sync(...): yield
  event` -> emit `yield from ...`.
- UP007: the SSE event union was `Union[A, B, ...]` -> emit `A | B | ...`.
- E712: the channel contract test asserted `== True`/`== False` -> emit
  `is True`/`is False`.

(Optional[X] field annotations are intentionally left for ruff's pyupgrade to
rewrite, per the existing design — unchanged here.) Verified: regenerating the
Python SDK + contract tests and running the regen's ruff sequence now passes
clean. Generator suite 300.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@calvin-archastro
calvin-archastro merged commit 290e96b into main Jun 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant