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
copy fails on collections.OrderedDict dataclass with required args #105736
Comments
|
@ringohoffman I can confirm the For the |
|
|
|
CC @rhettinger |
|
Here's a smaller reproducer: |
|
For copying to work in this case, the Also, even before copying, the example class isn't functional for the pure python |
|
@ericsnowcurrently Eric, do you have any thoughts on how we can (and/or whether we should) modify |
|
I don't have much stake in this, but that situation certainly gives me pause. We're already dealing with a dict subclass, which makes things dicey. Furthermore, subclassing is necessarily cooperative, particularly when |
…ersion (pythonGH-108098) (cherry picked from commit 20cc90c) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
…ersion (pythonGH-108098) (cherry picked from commit 20cc90c) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
|
Is there anything left to do here, or can we close this issue? |


Bug report
Related: huggingface/transformers#8978
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[4], line 39 35 a: int 36 b: int = 2 ---> 39 copy.deepcopy( 40 ModelOutput( 41 a=1, 42 b=2, 43 ) 44 ) File [...lib/python3.8/copy.py:172), in deepcopy(x, memo, _nil) 170 y = x 171 else: --> 172 y = _reconstruct(x, memo, *rv) 174 # If is its own copy, don't memoize. 175 if y is not x: File [.../lib/python3.8/copy.py:264), in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 262 if deep and args: 263 args = (deepcopy(arg, memo) for arg in args) --> 264 y = func(*args) 265 if deep: 266 memo[id(x)] = y TypeError: __init__() missing 1 required positional argument: 'a'Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: