Skip to content

bpo-44653: Support typing.Union in parameter substitution of the union type #27232

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 18, 2021

@serhiy-storchaka serhiy-storchaka force-pushed the union-subst-typing-union branch from d57f09e to a74e69f Compare July 18, 2021 16:50
Copy link
Member

@Fidget-Spinner Fidget-Spinner 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 please see my message on the bpo. There is another bug in the substitution.

@@ -0,0 +1 @@
Support ``typing.Union`` in parameter substitution of the union type.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is more specific:

Suggested change
Support ``typing.Union`` in parameter substitution of the union type.
Flatten ``typing.Union`` during parameter substitution of the union type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it better? Before this PR typing.Union was not supported at all.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm oh right I forgot. I think it's good to also mention that the arguments are flattened though, since none of the other types are treated like that. Some people might expect (int | T)[Union[str, int]] to become int | Union[str, int].

Suggested change
Support ``typing.Union`` in parameter substitution of the union type.
Support ``typing.Union`` in parameter substitution of the union type.
Arguments in ``typing.Union`` are flattened and merged into the
union type.

@serhiy-storchaka
Copy link
Member Author

There is more general approach in #27247.

@ambv
Copy link
Contributor

ambv commented Jul 22, 2021

Closing in favor of GH-27247.

@ambv ambv closed this Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review needs backport to 3.10 only security fixes type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants