bpo-36144: Add union operators to WeakValueDictionary584#19127
bpo-36144: Add union operators to WeakValueDictionary584#19127gvanrossum merged 5 commits intopython:masterfrom
Conversation
Updated weakref.py Added tests Updated docs Updated news
brandtbucher
left a comment
There was a problem hiding this comment.
Wow, you might get 3 PRs merged in one day!
Looks great, a couple of comments though:
Lib/test/test_weakref.py
Outdated
| wvd1 = weakref.WeakValueDictionary({1 : a}) | ||
| wvd2 = weakref.WeakValueDictionary({1 : b, 2 : a}) | ||
| wvd3 = wvd1.copy() | ||
| d1 = {1 : c, 3 : b} |
There was a problem hiding this comment.
No space before :, ever!
| wvd1 = weakref.WeakValueDictionary({1 : a}) | |
| wvd2 = weakref.WeakValueDictionary({1 : b, 2 : a}) | |
| wvd3 = wvd1.copy() | |
| d1 = {1 : c, 3 : b} | |
| wvd1 = weakref.WeakValueDictionary({1: a}) | |
| wvd2 = weakref.WeakValueDictionary({1: b, 2: a}) | |
| wvd3 = wvd1.copy() | |
| d1 = {1: c, 3: b} |
Lib/test/test_weakref.py
Outdated
| wvd2 = weakref.WeakValueDictionary({1 : b, 2 : a}) | ||
| wvd3 = wvd1.copy() | ||
| d1 = {1 : c, 3 : b} | ||
| pairs = [(5, c), (5, b)] |
There was a problem hiding this comment.
This is an interesting test case, but I just want to verify that you intended to use the same key twice here.
You didn't mean something like this, which results in a mapping of length 2?
| pairs = [(5, c), (5, b)] | |
| pairs = [(5, c), (6, b)] |
Lib/test/test_weakref.py
Outdated
| self.assertNotIn(2, tmp1.keys()) | ||
| self.assertNotIn(2, tmp2.keys()) | ||
| self.assertNotIn(1, tmp3.keys()) | ||
| self.assertNotIn(1, tmp4.keys()) |
There was a problem hiding this comment.
I don't think you need the keys() calls here:
| self.assertNotIn(2, tmp1.keys()) | |
| self.assertNotIn(2, tmp2.keys()) | |
| self.assertNotIn(1, tmp3.keys()) | |
| self.assertNotIn(1, tmp4.keys()) | |
| self.assertNotIn(2, tmp1) | |
| self.assertNotIn(2, tmp2) | |
| self.assertNotIn(1, tmp3) | |
| self.assertNotIn(1, tmp4) |
Doc/library/weakref.rst
Outdated
| .. versionchanged:: 3.9 | ||
| Added support for ``|`` and ``|=`` operators, specified in :pep:`584`. |
There was a problem hiding this comment.
I think this is better moved up to line 174, just after the ..note:: (and at the same indentation level).
There was a problem hiding this comment.
I think it should be more like line 200, because I believe line 174 is under WeakKeyDictionary rather than WeakValueDictionary?
Fixed styling and readibility.
There was a problem hiding this comment.
Thanks for the PR @curtisbucher. I agree with the inclusion of a versionadded for support of the union operators on dictionaries, it's a substantial new feature.
Grammar Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
|
@gvanrossum: Please replace |
|
Oops, screwed up the commit title. Oh well, we'll live. Thanks again @curtisbucher and @brandtbucher ! |
|
|
Buildbot failure looks unrelated. |
|
Agreed |
@brandtbucher
https://bugs.python.org/issue36144