-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Converter copy does not copy unstructure hooks #398
Comments
I think the head of the handler pairs needs to be copied, because we prepend new hooks to the front, but we are currently copying the tail. Maybe a change along these lines: diff --git a/src/cattrs/dispatch.py b/src/cattrs/dispatch.py
index f8a5445..c6542ea 100644
--- a/src/cattrs/dispatch.py
+++ b/src/cattrs/dispatch.py
@@ -137,4 +137,4 @@ class FunctionDispatch:
return len(self._handler_pairs)
def copy_to(self, other: "FunctionDispatch", skip: int = 0):
- other._handler_pairs.extend(self._handler_pairs[skip:])
+ other._handler_pairs = self._handler_pairs[:-skip] + other._handler_pairs |
Yeah you're right. The tests only test copying of singledispatch hooks, oops. Looking into it at #399 |
Should be fixed on main, let me know! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I wanted to create a base Converter with some common unstructuring hooks, then copy it in other places and add extra hooks. After copying the Converter I found that the unstructuring hooks from the source Converter no longer work.
What I Did
The text was updated successfully, but these errors were encountered: