Skip to content

Conversation

@ibraheemdev
Copy link
Member

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 09d2478 to 2e13754 Compare November 3, 2025 00:44
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

mypy_primer results

Changes were detected when running on open source projects
dulwich (https://github.com/dulwich/dulwich)
- dulwich/pack.py:1702:83: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 175 diagnostics
+ Found 174 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_validators.py:161:16: error[invalid-return-type] Return type does not match returned value: expected `Pattern[bytes]`, found `Pattern[str | bytes]`
+ pydantic/_internal/_validators.py:161:16: error[invalid-return-type] Return type does not match returned value: expected `Pattern[bytes]`, found `Pattern[bytes | str]`

pandera (https://github.com/pandera-dev/pandera)
+ tests/mypy/pandas_modules/pandas_dataframe.py:35:12: error[no-matching-overload] No overload of bound method `pipe` matches arguments
- tests/mypy/pandas_modules/pandas_dataframe.py:41:12: error[invalid-return-type] Return type does not match returned value: expected `DataFrame[SchemaOut]`, found `DataFrame[Schema] | DataFrame[SchemaOut]`
+ tests/mypy/pandas_modules/pandas_dataframe.py:41:12: error[invalid-return-type] Return type does not match returned value: expected `DataFrame[SchemaOut]`, found `DataFrame[SchemaOut] | DataFrame[Schema]`
- Found 1634 diagnostics
+ Found 1635 diagnostics

Expression (https://github.com/cognitedata/Expression)
- tests/test_result.py:491:21: error[invalid-argument-type] Argument to bound method `or_else` is incorrect: Expected `Result[Literal[42], Any]`, found `Result[Literal[0], Any]`
- tests/test_result.py:509:21: error[invalid-argument-type] Argument to bound method `or_else` is incorrect: Expected `Result[Any, Literal["original error"]]`, found `Result[Any, Literal["new error"]]`
- Found 200 diagnostics
+ Found 198 diagnostics

sphinx (https://github.com/sphinx-doc/sphinx)
- sphinx/domains/python/__init__.py:672:42: error[index-out-of-bounds] Index 0 is out of bounds for string `Literal[""]` with length 0
- Found 514 diagnostics
+ Found 513 diagnostics

vision (https://github.com/pytorch/vision)
- torchvision/prototype/transforms/_misc.py:34:13: error[invalid-assignment] Object of type `dict[Any, Sequence[int] & ~Top[dict[Unknown, Unknown]]]` is not assignable to `Sequence[int] | dict[type, Sequence[int] | None]`
- Found 1503 diagnostics
+ Found 1502 diagnostics

meson (https://github.com/mesonbuild/meson)
+ mesonbuild/build.py:1293:9: error[invalid-assignment] Object of type `list[Sequence[str | Literal[False]] | Literal[False]]` is not assignable to attribute `install_dir` of type `list[str | Literal[False]]`
- Found 1662 diagnostics
+ Found 1663 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/format.py:74:16: error[invalid-return-type] Return type does not match returned value: expected `PyprojectFormatter | dict[str, str]`, found `dict[str, Literal["*"]]`
- Found 49 diagnostics
+ Found 48 diagnostics

cloud-init (https://github.com/canonical/cloud-init)
- tests/unittests/sources/test_lxd.py:40:5: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- tests/unittests/test_net.py:5337:41: warning[possibly-missing-attribute] Attribute `keys` may be missing on object of type `Unknown | list[Unknown | str] | dict[Unknown | str, Unknown | str | None] | dict[Unknown, Unknown]`
- tests/unittests/test_net.py:5494:41: warning[possibly-missing-attribute] Attribute `keys` may be missing on object of type `Unknown | list[Unknown | str] | dict[Unknown | str, Unknown | str | None] | dict[Unknown | str, Unknown | str]`
- Found 1141 diagnostics
+ Found 1138 diagnostics

colour (https://github.com/colour-science/colour)
- colour/recovery/otsu2018.py:1606:21: error[invalid-assignment] Method `__setitem__` of type `Unknown | (Overload[(key: SupportsIndex, value: Unknown, /) -> None, (key: slice[Any, Any, Any], value: Iterable[Unknown], /) -> None]) | (bound method dict[Unknown, Unknown].__setitem__(key: Unknown, value: Unknown, /) -> None)` cannot be called with a key of type `Node_Otsu2018` and a value of type `Unknown | list[Unknown] | dict[Unknown, Unknown] | int` on object of type `Unknown | list[Unknown] | dict[Unknown, Unknown] | int`
- colour/recovery/otsu2018.py:1607:21: error[unsupported-operator] Operator `+=` is unsupported between objects of type `list[Unknown]` and `Literal[1]`
- colour/recovery/otsu2018.py:1607:21: error[unsupported-operator] Operator `+=` is unsupported between objects of type `dict[Unknown, Unknown]` and `Literal[1]`
- colour/recovery/otsu2018.py:1610:17: error[invalid-assignment] Method `__setitem__` of type `Unknown | (Overload[(key: SupportsIndex, value: Unknown, /) -> None, (key: slice[Any, Any, Any], value: Iterable[Unknown], /) -> None]) | (bound method dict[Unknown, Unknown].__setitem__(key: Unknown, value: Unknown, /) -> None)` cannot be called with a key of type `Node_Otsu2018` and a value of type `int` on object of type `Unknown | list[Unknown] | dict[Unknown, Unknown] | int`
- colour/recovery/otsu2018.py:1610:54: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | list[Unknown] | dict[Unknown, Unknown] | int`
- colour/recovery/otsu2018.py:1611:17: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `Unknown | list[Unknown] | dict[Unknown, Unknown] | int`
- Found 567 diagnostics
+ Found 561 diagnostics

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/test/unit/test_series.py:4489:37: error[no-matching-overload] No overload of function `round` matches arguments
- Found 2007 diagnostics
+ Found 2008 diagnostics

core (https://github.com/home-assistant/core)
+ homeassistant/components/homekit/config_flow.py:502:9: error[invalid-assignment] Object of type `Any` is not assignable to `EntityFilterDict`
+ homeassistant/components/homekit/config_flow.py:546:9: error[invalid-assignment] Object of type `Any` is not assignable to `EntityFilterDict`
+ homeassistant/components/homekit/config_flow.py:649:9: error[invalid-assignment] Object of type `Any` is not assignable to `EntityFilterDict`
- Found 14443 diagnostics
+ Found 14446 diagnostics
Memory usage changes were detected when running on open source projects
trio (https://github.com/python-trio/trio)
-     struct fields = ~10MB
+     struct fields = ~11MB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-assignment 4 3 0
invalid-argument-type 0 3 0
invalid-return-type 0 1 2
possibly-missing-attribute 0 3 0
no-matching-overload 2 0 0
unsupported-operator 0 2 0
index-out-of-bounds 0 1 0
non-subscriptable 0 1 0
unused-ignore-comment 0 1 0
Total 6 15 2

Full report with detailed diff (timing results)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 3, 2025

CodSpeed Performance Report

Merging #21210 will degrade performances by 9.23%

Comparing ibraheem/generic-call-inference (966b438) with main (ed18112)

Summary

❌ 5 regressions
✅ 17 untouched
⏩ 30 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Simulation hydra-zen 845.1 ms 919.5 ms -8.09%
WallTime medium[colour-science] 15 s 16.5 s -9.23%
WallTime medium[pandas] 42.7 s 45.6 s -6.39%
WallTime medium[static-frame] 12.8 s 13.5 s -5.19%
WallTime small[pydantic] 3 s 3.2 s -4.09%

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch 2 times, most recently from 9ad8d67 to 67143b9 Compare November 3, 2025 18:16
@ibraheemdev ibraheemdev changed the base branch from main to ibraheem/typed-dict-assignability November 3, 2025 18:18
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 67143b9 to 24e37e9 Compare November 3, 2025 18:18
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 24e37e9 to 54dec10 Compare November 3, 2025 20:35
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 54dec10 to e967176 Compare November 3, 2025 21:08
Base automatically changed from ibraheem/typed-dict-assignability to main November 3, 2025 21:57
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from e967176 to 0dc3902 Compare November 4, 2025 16:55
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 0dc3902 to a0144fd Compare November 4, 2025 17:37
@ibraheemdev ibraheemdev marked this pull request as ready for review November 4, 2025 20:25
@ibraheemdev ibraheemdev requested a review from carljm as a code owner November 4, 2025 20:25
@ibraheemdev
Copy link
Member Author

ibraheemdev commented Nov 4, 2025

I imagine we could avoid the performance regression by special casing x: ... | None = f() to avoid the inference attempt using only None as the type context, but I'm a little hesitant to make that change, as there are (rare) cases where we might want to narrow to None. Most of the regressions seem relatively reasonable, other than colour.

Also note that a lot of the diagnostic improvements won't be seen in this PR directly, but #20933 (which is currently stacked on top of this PR).

ibraheemdev added a commit that referenced this pull request Nov 5, 2025
…nce (#21275)

## Summary

Splitting this one out from #21210. This is also something that should be made obselete by the new constraint solver, but is easy enough to fix now.
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Do we understand what's causing the performance regression? Is it that we need to clone bindings or is it something else?

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 0f6ddfb to 2b79ab0 Compare November 6, 2025 14:47
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 2b79ab0 to 0629a65 Compare November 6, 2025 15:22
@ibraheemdev
Copy link
Member Author

Most of the performance regressions have been resolved. There is an unavoidable regression when assigning the result of a generic call to a union, as we have to attempt inference multiple times for each element of the union.

@carljm
Copy link
Contributor

carljm commented Nov 6, 2025

Can you take a look at the new diagnostics in the ecosystem report? Just taking a quick glance, I see in HomeAssistant a few occurrences of "object of type Any is not assignable ..." which definitely doesn't look right.

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Nov 6, 2025

It looks like those failures are due to TypedDict being assignable to None, which confuses overload evaluation. The weird diagnostic should be fixed by #21267, the actual type we infer (with type context) is Any | None there, not Any.

I added a failing test to track those.

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch 2 times, most recently from a786a14 to 46b938b Compare November 7, 2025 15:38
@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-call-inference branch from 46b938b to 966b438 Compare November 7, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants