Files
Ali KhokharandClaude Opus 5.5 3c83b78e20 patch: Fail type checks on Any returns, unknown returns and unknown attributes (#2607)
## Why

Pyrefly's strict preset leaves the Any checks off. Three of them cost
almost nothing to turn on: `no-any-return` (a function declared to
return a concrete type returns `Any`), `unknown-return-type` and
`unknown-attribute-type`. Together they report 22 sites. Each site is a
value whose type nobody checks.

The larger Any checks (`explicit-any`, `unknown-variable-type`,
`unknown-argument-type`, `partially-unknown-type`) are left for later.
`partially-unknown-type` waits for a Pyrefly release that types `async
def` coroutines (facebook/pyrefly#5720).

## How

- `pyproject.toml` turns on the three checks as errors.
- At JSON and SDK boundaries (`json.loads`, `response.json()`,
markdown-it, urllib, ruamel, `AsyncMock`), the value is assigned to an
annotated local before it is returned. This is the pattern
`catalog_http.py` and `managed/claude.py` already use.
- `ContinuationRequest` casts the Responses input the way its
neighbouring returns already do.
- The Vertex token provider only returns a cached Google token when it
is a non-empty `str`; google-auth leaves `token` untyped. A truthy
non-string token now goes through the refresh path, which already
rejects it.
- `openai_error_from_failure` builds the inner error directly instead of
wrapping it in an envelope and indexing it back out.
- The Codex smoke test types its event queue. That exposed two chained
`.get` calls on nested JSON, which now go through `object_payload`.
- The thread-dump pytest hook gets its generator return type.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- greptile_comment -->

<!-- greptile_summary -->

<h2>Confidence Score: 5/5<a
href="https://app.greptile.com/api/retrigger?id=126409510&amp;sig=34d3ee34f8e7572fb1f0712bbd8a2cd8eb21f8ae5929a234a153aff3ca354635"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=alishahryar1&amp;next=%2FAlishahryar1%2Ffree-claude-code%2Fpull%2F2607&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a></h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge; no
actionable issues were found.

<details open><summary><h3>Summary</h3></summary>

The PR enables three stricter Pyrefly checks and adds types at JSON and
SDK boundaries.
- Pyrefly now flags unclear return and attribute types as errors.
- Vertex authentication reuses cached tokens only when they are
non-empty strings.
- OpenAI error responses now build their inner error details directly.

No actionable issues were found. Tests and type checks were not run.

Alishahryar1 explicitly described rejecting truthy non-string Vertex
tokens as intentional in the PR description.
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (1) · Last reviewed commit: ["Fail type checks on Any
returns,
unknown..."](https://github.com/alishahryar1/free-claude-code/commit/2d68438ff3fa6340f1eb8f0655118b07bb691939)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=alishahryar1/free-claude-code)</sub>

<!-- /greptile_comment -->

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 00:51:50 -08:00
..