Skip to content

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Sep 25, 2025

Summary

This removes a hack in the protocol satisfiability check that was previously needed to work around missing assignability-modeling of inferable type variables. Assignability of type variables is not implemented fully, but some recent changes allow us to remove that hack with limited impact on the ecosystem (and the test suite). The change in the typing conformance test is favorable.

Test Plan

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Sep 25, 2025
Copy link
Contributor

github-actions bot commented Sep 25, 2025

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-09-25 11:25:37.323644940 +0000
+++ new-output.txt	2025-09-25 11:25:40.505639553 +0000
@@ -430,6 +430,7 @@
 generics_self_basic.py:75:5: error[type-assertion-failure] Argument does not have asserted type `Container[str]`
 generics_self_basic.py:83:5: error[type-assertion-failure] Argument does not have asserted type `Container[T@object_with_generic_type]`
 generics_self_protocols.py:48:5: error[type-assertion-failure] Argument does not have asserted type `ShapeProtocol`
+generics_self_protocols.py:61:19: error[invalid-argument-type] Argument to function `accepts_shape` is incorrect: Expected `ShapeProtocol`, found `BadReturnType`
 generics_self_usage.py:73:14: error[invalid-type-form] Variable of type `typing.Self` is not allowed in a type expression
 generics_self_usage.py:73:23: error[invalid-type-form] Variable of type `typing.Self` is not allowed in a type expression
 generics_self_usage.py:76:6: error[invalid-type-form] Variable of type `typing.Self` is not allowed in a type expression
@@ -860,5 +861,5 @@
 typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
 typeddicts_usage.py:28:18: error[invalid-key] Invalid key access on TypedDict `Movie`: Unknown key "title"
 typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions. Did you mean to use a concrete TypedDict or `collections.abc.Mapping[str, object]` instead?
-Found 861 diagnostics
+Found 862 diagnostics
 WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details.

Copy link
Contributor

github-actions bot commented Sep 25, 2025

mypy_primer results

Changes were detected when running on open source projects
antidote (https://github.com/Finistere/antidote)
+ src/antidote/lib/interface_ext/_internal.py:132:27: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Predicate[Weight@create_conditions] | Weight@create_conditions | NeutralWeight | None | bool`, found `QualifiedBy`
+ src/antidote/lib/interface_ext/_internal.py:134:27: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Predicate[Weight@create_conditions] | Weight@create_conditions | NeutralWeight | None | bool`, found `QualifiedBy`
- tests/lib/interface/test_conditions.py:193:45: error[invalid-argument-type] Argument to bound method `when` is incorrect: Expected `Predicate[Weight | None] | Weight | None | NeutralWeight | bool`, found `OnlyIf`
- Found 304 diagnostics
+ Found 305 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/_wheelfile.py:51:22: error[no-matching-overload] No overload of function `field` matches arguments
- Found 52 diagnostics
+ Found 53 diagnostics

jax (https://github.com/google/jax)
+ jax/experimental/pallas/ops/gpu/attention_mgpu.py:461:9: error[invalid-argument-type] Argument to function `emit_pipeline_warp_specialized` is incorrect: Expected `ComputeContext | None`, found `def _compute_thread(pipeline_callback) -> Unknown`
+ jax/experimental/pallas/ops/gpu/attention_mgpu.py:568:7: error[invalid-argument-type] Argument to function `emit_pipeline_warp_specialized` is incorrect: Expected `ComputeContext | None`, found `def _compute_thread(pipeline_callback) -> Unknown`
+ jax/experimental/pallas/ops/gpu/attention_mgpu.py:755:9: error[invalid-argument-type] Argument to function `emit_pipeline_warp_specialized` is incorrect: Expected `ComputeContext | None`, found `def _compute_thread(pipeline_callback) -> Unknown`
- Found 2251 diagnostics
+ Found 2254 diagnostics
Memory usage changes were detected when running on open source projects
flake8 (https://github.com/pycqa/flake8)
-     memo metadata = ~6MB
+     memo metadata = ~5MB

@sharkdp sharkdp force-pushed the david/remove-protocol-satisfiability-hack branch from c38d6d3 to 6c9cbc0 Compare September 25, 2025 10:20
@sharkdp sharkdp marked this pull request as ready for review September 25, 2025 10:58

class NewStyleClassScoped[T](Protocol):
def method(self, input: T) -> None: ...
def method(self: Self, input: T) -> None: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove these Self annotations again in the type-of-self PR.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd love to add some of the tests I added in #20569 (see #20569 (comment))

@sharkdp sharkdp merged commit efbb80f into main Sep 25, 2025
38 checks passed
@sharkdp sharkdp deleted the david/remove-protocol-satisfiability-hack branch September 25, 2025 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants