Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Oct 10, 2025

When inferring a precise generator return type for an async def (or generator), make the generate returned by an override in a subclass inherit from the base class generator. This means that the environment has to be moved to a separate class in the base class generator.

Don't infer a precise generator return type when an override might have a less precise return type, since it would break LSP.

Fixes mypyc/mypyc#1141.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Oct 10, 2025

I'm still missing at least non-async generator inheritance tests.

@JukkaL JukkaL merged commit b3e26e7 into master Oct 14, 2025
13 checks passed
@JukkaL JukkaL deleted the mypyc-inherit-bug branch October 14, 2025 09:45
JukkaL added a commit that referenced this pull request Nov 18, 2025
Disable optimization that doesn't work for trait methods. We could
probably make the optimization work properly, but it would take
significant work, so focus on fixing a regression.

Fixes mypyc/mypyc#1141. #20044 was a previous fix attempt that fixes
some other use cases, but it didn't address traits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError with async methods and inheritance

3 participants