mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-22 09:50:54 +08:00
## Summary
When ty checks `{"type": "union", "choices": [{"type": "int"}, {"type":
"float"}]}` against Pydantic Core's `CoreSchema`, it tries all 59
`TypedDict`s. It infers `choices` even for schemas that require a
different `type` tag.
We now skip a candidate before inferring the values if a required key is
missing or a required string tag conflicts with the literal. We check
dictionaries whose keys are all string literals, using the last value
for repeated keys. A computed key or a `**` unpack could supply a
missing field or overwrite a tag.
Cold checks used 12.69–12.91% fewer instructions on the Pydantic Core
project (134 files) and 62.15–62.17% fewer on `tests/test_typing.py`
alone. The OpenAI Agents SDK's `tests/extensions/memory/` directory used
10.56–10.65% fewer. [Pydantic
Core](https://github.com/pydantic/pydantic/tree/560f0f96a37d6913afdfddb2de22030ef08e68c3/pydantic-core)
· [Agents SDK memory
tests](https://github.com/openai/openai-agents-python/tree/6c4e4a29cd08eef454db6980d74da6afc8939d24/tests/extensions/memory)
## Pinned projects
The Pydantic row checks the 55 files in the `pydantic/` package. In a
separate serial repeat, both pytest pairs used 0.16% fewer instructions,
within the 0.35% variation between consecutive checks with the same
binary.
| Project | [Base
instructions](https://github.com/astral-sh/ruff/commit/a866aff503fd777156c1ae4eae318a3795fa09ec)
| [PR
instructions](https://github.com/astral-sh/ruff/commit/1115003f608598a821d1aa7efeb0fefc1e7acd73)
| Change | Paired range |
| --- | ---: | ---: | ---: | ---: |
|
[Black](https://github.com/psf/black/tree/55996d1fb8342725c8a19b6023cd9439c3c1d6f7)
(inconclusive) | 3,180,362,811 | 3,173,024,995.5 | -0.23% | -0.43% to
-0.03% |
|
[discord.py](https://github.com/Rapptz/discord.py/tree/65232c38702be5844cf2ce865a4777eb1928b5d0)
(inconclusive) | 8,250,316,762.5 | 8,256,364,824.5 | +0.07% | -0.07% to
+0.22% |
| [Home
Assistant](https://github.com/home-assistant/core/tree/c19ae285ede74cd64c3045a3a4aa43290c224f1b)
| 159,284,924,031 | 159,224,734,983.5 | -0.04% | -0.04% to -0.03% |
|
[isort](https://github.com/pycqa/isort/tree/a514c71ed86c2216d0040c7d60e302ed76a4f7ab)
(inconclusive) | 1,857,160,007.5 | 1,856,125,205 | -0.05% | -0.46% to
+0.35% |
|
[Jinja](https://github.com/pallets/jinja/tree/5ef70112a1ff19c05324ff889dd30405b1002044)
(inconclusive) | 1,946,982,759 | 1,942,539,120 | -0.23% | -0.35% to
-0.11% |
|
[pandas](https://github.com/pandas-dev/pandas/tree/a0225b65720018f4654390bb16d254daa6ee5e54)
(inconclusive) | 28,824,498,732.5 | 28,796,162,668 | -0.10% | -0.11% to
-0.09% |
|
[pandas-stubs](https://github.com/pandas-dev/pandas-stubs/tree/8dd6d91b1c05b26e30f7ddbe3dc3d4042a92bdd6)
(inconclusive) | 2,975,041,644.5 | 2,970,777,113.5 | -0.14% | -0.27% to
-0.02% |
|
[Prefect](https://github.com/PrefectHQ/prefect/tree/a9452ac21852755311913cb27887b083b5007c03)
(inconclusive) | 4,958,548,140.5 | 4,958,263,017.5 | -0.01% | -0.01% to
0.00% |
|
[PyTorch](https://github.com/pytorch/pytorch/tree/ab92945cea42e47ae398aead69af0872d340ea0f)
| 96,649,807,586.5 | 96,600,313,311.5 | -0.05% | -0.06% to -0.05% |
|
[HTTPX](https://github.com/encode/httpx/tree/b5addb64f0161ff6bfe94c124ef76f6a1fba5254)
(inconclusive) | 1,682,000,652.5 | 1,683,197,725 | +0.07% | +0.06% to
+0.08% |
|
[NumPy](https://github.com/numpy/numpy/tree/f9f1772ce010001208475f751d19253469788410)
(inconclusive) | 8,554,986,848 | 8,557,857,817 | +0.03% | -0.03% to
+0.10% |
|
[FastAPI](https://github.com/fastapi/fastapi/tree/7a0a3f0b286c6c865cf4398ea0e957a87b8bffa4)
(inconclusive) | 3,007,194,779 | 3,005,986,069.5 | -0.04% | -0.06% to
-0.02% |
|
[SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy/tree/10f4d1e2d706a7722ca78e79ce05b00333a7aa5b)
(inconclusive) | 21,539,239,584.5 | 21,520,156,231 | -0.09% | -0.18% to
0.00% |
|
[Rich](https://github.com/Textualize/rich/tree/9d8f9a372cc5916fd4781fec207ced7ddac2f08f)
(inconclusive) | 2,727,630,208.5 | 2,722,386,665.5 | -0.19% | -0.43% to
+0.05% |
|
[Django](https://github.com/django/django/tree/b501b8493f31cf8cba31211d59b3b78642b8cb02)
(inconclusive) | 13,908,902,990 | 13,908,079,615.5 | -0.01% | -0.12% to
+0.11% |
|
[SymPy](https://github.com/sympy/sympy/tree/85d3998a4517ffbc8a9709b8efa769bb417c174a)
(inconclusive) | 46,169,520,073.5 | 46,165,531,525.5 | -0.01% | -0.05%
to +0.03% |
| [OpenAI Python
SDK](https://github.com/openai/openai-python/tree/f6e8480f9a5b2a4d02b17a1da54a1e57964bc312)
(inconclusive) | 16,020,695,437 | 15,997,906,899 | -0.14% | -0.19% to
-0.09% |
|
[pytest](https://github.com/pytest-dev/pytest/tree/8b005ed7f972987033ec34dc1e68b0635fb8142b)
| 8,811,494,792 | 8,816,893,703 | +0.06% | +0.04% to +0.08% |
|
[aiohttp](https://github.com/aio-libs/aiohttp/tree/fe099491d275ef2c21bf683e024e34d51ac05d43)
(inconclusive) | 4,174,314,733 | 4,174,752,847.5 | +0.01% | -0.07% to
+0.09% |
|
[Ansible](https://github.com/ansible/ansible/tree/b4b2b1e82a535d27f902a71fc8396c3af138fca2)
| 14,459,679,374 | 14,446,949,627 | -0.09% | -0.12% to -0.05% |
|
[botocore](https://github.com/boto/botocore/tree/e250abbe956da791c16086575e6ddb1f2da81a78)
(inconclusive) | 3,027,633,125.5 | 3,026,012,940 | -0.05% | -0.17% to
+0.06% |
|
[Celery](https://github.com/celery/celery/tree/9c2f238334331db43f15956f131235fd3bb70fd1)
(inconclusive) | 4,823,887,962 | 4,822,076,737 | -0.04% | -0.14% to
+0.06% |
|
[Dask](https://github.com/dask/dask/tree/249a51a1db4261791b93b4ce04e67341729939c3)
| 34,992,809,088.5 | 34,952,789,155.5 | -0.11% | -0.16% to -0.07% |
|
[NetworkX](https://github.com/networkx/networkx/tree/6855cd586982cc2e4710b8eb87251ccf56674bf1)
| 15,759,940,126.5 | 15,742,537,811.5 | -0.11% | -0.12% to -0.10% |
|
[Pydantic](https://github.com/pydantic/pydantic/tree/560f0f96a37d6913afdfddb2de22030ef08e68c3)
| 13,066,992,993.5 | 13,049,033,053.5 | -0.14% | -0.14% to -0.14% |
|
[scikit-learn](https://github.com/scikit-learn/scikit-learn/tree/ee56c8b5d809dc7b970a140ed501269b63c69cf8)
(inconclusive) | 66,866,675,196.5 | 66,857,495,258.5 | -0.01% | -0.05%
to +0.03% |
|
[Scrapy](https://github.com/scrapy/scrapy/tree/e63a574c767d7a9438c21db158f605f1c44c6e6a)
(inconclusive) | 8,977,022,049.5 | 8,975,774,708.5 | -0.01% | -0.04% to
+0.02% |
|
[Transformers](https://github.com/huggingface/transformers/tree/3a134bc37f7c22c801b618e289b0255425f22647)
(inconclusive) | 102,128,236,207 | 102,066,149,367.5 | -0.06% | -0.13%
to 0.00% |