Skip to content

[red-knot] Fix type inference for except* definitions #13320

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

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

AlexWaygood
Copy link
Member

Once again, async Python requires different inference rules to sync Python!

A new DefinitionNodeRef::ExceptStarHandler variant is introduced, so that we can differentiate between except-handler definitions in StmtTry { is_star: true } nodes and those in StmtTry { is_star: false } nodes. The logic for adding these definitions is also moved in builder.rs so that we can know whether the try block is catching exceptions or exception groups. (We'll need to move the logic there anyway when adding control flow for these definitions.)

Lots of TODOs here, but I think inferring Instance(BaseExceptionGroup) is better than just inferring Unknown for these definitions.

The PR is stacked on top of #13319

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Sep 10, 2024
Copy link
Contributor

github-actions bot commented Sep 10, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Base automatically changed from alex/redknot-to-instance to main September 10, 2024 22:41
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

🎉

@AlexWaygood AlexWaygood merged commit 4dc2c25 into main Sep 11, 2024
20 checks passed
@AlexWaygood AlexWaygood deleted the alex/async-except branch September 11, 2024 19:05
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.

3 participants