KEMBAR78
Make TypeAdapter's typing compatible with special forms by adriangb · Pull Request #8923 · pydantic/pydantic · GitHub
Skip to content

Conversation

@adriangb
Copy link
Member

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90f5d0b
Status: ✅  Deploy successful!
Preview URL: https://205bc39a.pydantic-docs2.pages.dev
Branch Preview URL: https://type-adapter-typing.pydantic-docs2.pages.dev

View logs

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 29, 2024

CodSpeed Performance Report

Merging #8923 will not alter performance

Comparing type-adapter-typing (90f5d0b) with main (4b31fd7)

Summary

✅ 10 untouched benchmarks

Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for adding the comment as well 👍

@sydney-runkle sydney-runkle added the relnotes-fix Used for bugfixes. label Feb 29, 2024
@sydney-runkle sydney-runkle merged commit 575f473 into main Feb 29, 2024
@sydney-runkle sydney-runkle deleted the type-adapter-typing branch February 29, 2024 20:32
blast-hardcheese added a commit to replit/river-python that referenced this pull request Aug 19, 2024
Why
===

Any place we might encounter a `Union[...]`, we need `# type:
ignore[arg-type]` to avoid mypy failing to typecheck, due to
pydantic/pydantic#8923, acknowledging that while
pyright seems to have good inference, mypy fails to typecheck.

To better understand the issue and determine if there were any
workarounds, I created
https://github.com/blast-hardcheese/mypy-union-bug with the intent to
report upstream, before finding the ongoing discussion threads linked
here and in comments.

What changed
============

### Main

- Reflow format strings to use multiline format strings and
`indent(dedent(s, ...))`. This gives us more horizontal space instead of
trying to use C-style line continuation to avoid the 88-character limit
- Adding `# type: ignore[arg-type]` to possible `Union` slots

### 🧹 
- Tracking type literals more closely
- Reducing nested format strings for clarity
- Bubble up string-formatted comma for intelligibility

Test plan
=========

Manually running against production schemas, gathering sources together
for a sensible local test suite for codegen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants