-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-128615: Cover pickling of ParamSpecArgs
and ParamSpecKwargs
#128616
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5182,6 +5182,18 @@ class C(B[int]): | |
x = pickle.loads(z) | ||
self.assertEqual(s, x) | ||
|
||
# Test ParamSpec args and kwargs | ||
global PP | ||
PP = ParamSpec('PP') | ||
for thing in [PP.args, PP.kwargs]: | ||
for proto in range(pickle.HIGHEST_PROTOCOL + 1): | ||
with self.subTest(thing=thing, proto=proto): | ||
self.assertEqual( | ||
pickle.loads(pickle.dumps(thing, proto)), | ||
thing, | ||
) | ||
del PP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be some sort of context manager so that should we also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are multiple places where this pattern is used. I think that it should be fine, because the only problem that I can think of is that But, this can be refactored in the future, if desired. |
||
|
||
def test_copy_and_deepcopy(self): | ||
T = TypeVar('T') | ||
class Node(Generic[T]): ... | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be combined into the
global
statement at the top of the function? (global C, PP
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feel more readable to have this name defined as
global
near the place where this is needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I don't feel strongly :)