python-attrs / cattrs

Composable custom class converters for attrs, dataclasses and friends.
https://catt.rs
MIT License
791 stars 110 forks source link

Make validation notes picklable. #408

Closed PIG208 closed 1 year ago

PIG208 commented 1 year ago

Certain test runners (in my case, Django's RemoteTestRunner) pickle the exceptions raised to accumulate them from multiple processes.

For exceptions with AttributeValidationNote and/or IterableValidationNote attached, because we have overridden __new__ on these classes, pickle cannot correctly unpickle them with the required arguments. For this use case, exceptions being pickable is necessary to accumulate errors with the multiprocessing setup.

This implements __getnewargs__ to fix this problem.

Tinche commented 1 year ago

Thanks!