From 6cacddad7a69a32becd63cdc8017d4ed8e255730 Mon Sep 17 00:00:00 2001 From: Amethyst Reese Date: Tue, 24 Oct 2023 12:57:19 -0700 Subject: [PATCH] Make CollectionError pickleable CollectionError could not be unpickled because the default `Exception.__reduce__` implementation does not include any attributes/values that weren't passed to the superclass constructor, resulting in a failure when unpickling the exception in the parent class because the `rule` argument wasn't given. This updates the class to add a custom `__reduce__` that fixes the ability to pickle/unpickle the class correctly, fixing the primary issue with exceptions during linting resulting in broken process pools. Fix #381 ghstack-source-id: d8bd29c52d8320ee33a7f43937df6dc4e883d90d Pull Request resolved: https://github.com/Instagram/Fixit/pull/401 --- src/fixit/config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fixit/config.py b/src/fixit/config.py index 8b596092..79b3b8be 100644 --- a/src/fixit/config.py +++ b/src/fixit/config.py @@ -69,6 +69,9 @@ def __init__(self, msg: str, rule: QualifiedRule): super().__init__(msg) self.rule = rule + def __reduce__(self): + return type(self), (*self.args, self.rule) + def is_rule(obj: Type[T]) -> bool: """