Skip to content

Understand type[A | B] special form in annotations#14830

Merged
carljm merged 2 commits intoastral-sh:mainfrom
Glyphack:typing-type-union
Dec 7, 2024
Merged

Understand type[A | B] special form in annotations#14830
carljm merged 2 commits intoastral-sh:mainfrom
Glyphack:typing-type-union

Conversation

@Glyphack
Copy link
Copy Markdown
Contributor

@Glyphack Glyphack commented Dec 7, 2024

resolves #14703

I decided to use recursion to get the type, so if anything is added to the single element inference it will be applied for the union.
Also added this change in this PR since it was easy.

@Glyphack Glyphack marked this pull request as draft December 7, 2024 15:21
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 7, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@Glyphack Glyphack marked this pull request as ready for review December 7, 2024 16:32
Copy link
Copy Markdown
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.

Looks great, thank you!

Comment thread crates/red_knot_python_semantic/src/types/infer.rs Outdated
Comment thread crates/red_knot_python_semantic/resources/mdtest/type_of/basic.md Outdated
@carljm carljm enabled auto-merge (squash) December 7, 2024 17:30
@carljm carljm merged commit 269e47b into astral-sh:main Dec 7, 2024
@Glyphack Glyphack deleted the typing-type-union branch December 7, 2024 18:06
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.

[red-knot] understand type[A | B] where A and B are both classes

2 participants