-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: exit serialization early on detection of a cycle #78
Conversation
Codecov Report
@@ Coverage Diff @@
## master #78 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 14 14
Lines 527 540 +13
=====================================
+ Hits 527 540 +13
Continue to review full report at Codecov.
|
src/syrupy/serializers/amber.py
Outdated
@@ -89,7 +92,9 @@ def object_type(cls, data: "SerializableData") -> str: | |||
return f"<class '{data.__class__.__name__}'>" | |||
|
|||
@classmethod | |||
def serialize_string(cls, data: "SerializableData", indent: int = 0) -> str: | |||
def serialize_string( | |||
cls, data: "SerializableData", *, indent: int = 0, visited: List[Any] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove the unused visited
kwarg if we do **_
, not sure how mypy handles that though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it complained last I tried, will attempt again but treating as non blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much refactoring needed to satisfy mypy and ignore the argument, leaving as is
Description
Tracks visited items in serialization and exits early when cycle is encountered or max depth exceeded
Related Issues
Checklist
Additional Comments