Skip to content

bpo-38979: fix ContextVar "__class_getitem__" method#17497

Merged
miss-islington merged 7 commits into
python:masterfrom
amiremohamadi:contextvar-getitem
Dec 8, 2019
Merged

bpo-38979: fix ContextVar "__class_getitem__" method#17497
miss-islington merged 7 commits into
python:masterfrom
amiremohamadi:contextvar-getitem

Conversation

@amiremohamadi

@amiremohamadi amiremohamadi commented Dec 7, 2019

Copy link
Copy Markdown
Contributor

now contextvars.ContextVar "class_getitem" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov

@@ -0,0 +1,3 @@
return class from __class_getitem__ to simplify subclassing. E.g. `clss =
contextvars.ContextVar[str]` returned `None` instead of `<class

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMHO there is no need for examples for this fix

@isidentical

Copy link
Copy Markdown
Member

def test_context_var_new_2(self):
self.assertIsNone(contextvars.ContextVar[int])

You need to remove this test

@@ -0,0 +1,3 @@
return class from __class_getitem__ to simplify subclassing. E.g. `clss =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might want to use double backtick for __class_getitem__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with both @isidentical comments. @amiremohamadi please address them.
Otherwise, the PR looks awesome.

@@ -0,0 +1,3 @@
return class from __class_getitem__ to simplify subclassing. E.g. `clss =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with both @isidentical comments. @amiremohamadi please address them.
Otherwise, the PR looks awesome.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@asvetlov

asvetlov commented Dec 7, 2019

Copy link
Copy Markdown
Contributor

Since __class_getitem__ was here starting from Python 3.7 I think that the backport of the fix makes sense.

It cannot break any code.

@amiremohamadi

Copy link
Copy Markdown
Contributor Author

@asvetlov, @isidentical thanks for your help! :)
I have made the requested changes; please review again

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@asvetlov: please review the changes made to this pull request.

@bedevere-bot
bedevere-bot requested a review from asvetlov December 7, 2019 16:44
Comment thread Lib/test/test_context.py
@miss-islington

Copy link
Copy Markdown
Contributor

@amiremohamadi: Status check is done, and it's a success ✅ .

@miss-islington
miss-islington merged commit 28c9163 into python:master Dec 8, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @amiremohamadi for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 8, 2019
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c9163)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
@bedevere-bot

Copy link
Copy Markdown

GH-17505 is a backport of this pull request to the 3.8 branch.

@bedevere-bot

Copy link
Copy Markdown

GH-17506 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 8, 2019
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c9163)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Dec 8, 2019
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c9163)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @amiremohamadi for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-17507 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 8, 2019
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c9163)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Dec 8, 2019
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c9163)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None. 


https://bugs.python.org/issue38979



Automerge-Triggered-By: @asvetlov
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.

6 participants