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

bpo-44662: Add ability to annotate types.Union #27214

Merged
merged 10 commits into from
Jul 29, 2021
Merged

Conversation

uriyyo
Copy link
Member

@uriyyo uriyyo commented Jul 17, 2021

@uriyyo
Copy link
Member Author

uriyyo commented Jul 17, 2021

@Fidget-Spinner Could you please review this PR?

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.

Please wait until Serhiy merges some of his union refactoring changes. He's already prepared them, just not yet made PRs for review and merge. This will also take some time for me to review as I need to revise on tp_getattro and friends. Sorry (I'm busy with other things at the moment).

Also the current issue is getting too big. Can you please create a separate issue for this on bpo then tie this PR to that? We are getting pretty far from my original issue on the bpo ;).

@uriyyo uriyyo changed the title bpo-44490: Add ability to serialise and annotate types.Union bpo-44662: Add ability to serialise and annotate types.Union Jul 17, 2021
@uriyyo
Copy link
Member Author

uriyyo commented Jul 17, 2021

I created separate issue at issue tracker.

@uriyyo uriyyo force-pushed the fix-issue-44490 branch from 97a1898 to eb52dc8 Compare July 19, 2021 09:04
@uriyyo uriyyo requested a review from Fidget-Spinner July 19, 2021 09:15
@uriyyo
Copy link
Member Author

uriyyo commented Jul 19, 2021

@Fidget-Spinner I have merged Serhiy changes. Could you please review this PR?

@Fidget-Spinner
Copy link
Member

Can you please split the PR into two? It seems it's fixing pickling and typing.Annotated compatibility at the same time. Please create another issue for the annotated problem.

@uriyyo
Copy link
Member Author

uriyyo commented Jul 19, 2021

Sorry about that, I thought that it will be a great idea to fix several issues in scope of one PR.

I will divide it at 2 separate PR.

@uriyyo uriyyo changed the title bpo-44662: Add ability to serialise and annotate types.Union bpo-44662: Add ability to annotate types.Union Jul 19, 2021
@uriyyo
Copy link
Member Author

uriyyo commented Jul 19, 2021

@Fidget-Spinner This PR contains only typing.Annotated compatibility fix.

@Fidget-Spinner
Copy link
Member

Sorry about that, I thought that it will be a great idea to fix several issues in scope of one PR.

I will divide it at 2 separate PR.

No worries. Thanks for separating them. It's much clearer to me now.

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.

Looks good, I'll nosy a few others in too in case I missed something.

uriyyo and others added 2 commits July 19, 2021 19:55
…62.q22kWR.rst

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
@uriyyo uriyyo requested a review from Fidget-Spinner July 19, 2021 17:04
@uriyyo
Copy link
Member Author

uriyyo commented Jul 25, 2021

@Fidget-Spinner This PR is ready to be review. Could you please do it?)

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Jul 25, 2021

I'm thinking about whether we should just fix typing._GenericAlias to look for type(o).__module__ if o.__module__ doesn't exist. It seems easier than passing lookups to the parent type in types.Union.

types.GenericAlias is a little special because it's supposed to be nearly completely transparent and pass everything to __origin__. But no other builtin type behaves like this. Eg. {}.__module__ doesn't have __name__ or __qualname__ etc. Then again, types.Union isn't like the other builtin types is it?

I'll ping Łukasz when it's monday for him. Or maybe Jelle can give his opinion too.

Off topic: I'm trying not to review stuff on sundays so that I have more time to work on other things :). So in the future I won't be able to respond very quickly to review requests on sunday.

@Fidget-Spinner
Copy link
Member

@ambv or @JelleZijlstra what do y'all think? Should we fix the typing module's Annotated or fix types.Union?

@JelleZijlstra
Copy link
Member

I haven't looked deeply but in general I'd prefer to make Annotated do as little runtime checking as possible, so we don't have to jump through hoops to make things like Union work with it.

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.

I haven't looked deeply but in general I'd prefer to make Annotated do as little runtime checking as possible, so we don't have to jump through hoops to make things like Union work with it.

Thanks for your input Jelle :).

LGTM mostly. I'm convinced we should add __module__ to Union now. Thanks for your efforts Yurii.

@uriyyo uriyyo requested a review from Fidget-Spinner July 26, 2021 09:36
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.

Thanks

@ambv ambv added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 29, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ambv for commit b931632 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 29, 2021
@ambv ambv merged commit 8182c83 into python:main Jul 29, 2021
@bedevere-bot
Copy link

@ambv: Please replace # with GH- in the commit message next time. Thanks!

@miss-islington
Copy link
Contributor

Thanks @uriyyo for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-27461 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 29, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 29, 2021
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 8182c83)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
ambv pushed a commit that referenced this pull request Jul 30, 2021
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 8182c83)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
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.

7 participants