Skip to content

Commit

Permalink
Make CollectionError pickleable
Browse files Browse the repository at this point in the history
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: #401
  • Loading branch information
amyreese committed Oct 24, 2023
1 parent 21360fe commit 6cacdda
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fixit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 6cacdda

Please sign in to comment.