Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] simplify type lookup in function/class definitions #14303

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Conversation

carljm
Copy link
Contributor

@carljm carljm commented Nov 13, 2024

When we look up the types of class bases or keywords (metaclass), we currently do this little dance: if there are type params, then look up the type using SemanticModel in the type-params scope, if not, look up the type directly in the definition's own scope, with support for deferred types.

With inference of function parameter types, I'm now adding another case of this same dance, so I'm motivated to make it a bit more ergonomic.

Add support to definition_expression_ty to handle any sub-expression of a definition, whether it is in the definition's own scope or in a type-params sub-scope.

Related to both #13693 and #14161.

@carljm carljm added the red-knot Multi-file analysis & type inference label Nov 13, 2024
Copy link
Contributor

github-actions bot commented Nov 13, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@carljm carljm enabled auto-merge (squash) November 13, 2024 13:49
@carljm carljm merged commit 5fcf0af into main Nov 13, 2024
16 checks passed
@carljm carljm deleted the cjm/deftypes branch November 13, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants