-
-
Notifications
You must be signed in to change notification settings - Fork 32
[Issue24] Prevent Schema Mutation #26
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
Conversation
Hi @p1c2u, I hope you are doing well. Please, let me know your code review comments. cc/ @sebastianmika |
Hey @p1c2u, I'm following up on this PR code review. Please, let me know your thoughts. cc/ @sebastianmika |
Codecov Report
@@ Coverage Diff @@
## master #26 +/- ##
===========================================
+ Coverage 59.89% 71.19% +11.30%
===========================================
Files 6 6
Lines 182 184 +2
===========================================
+ Hits 109 131 +22
+ Misses 73 53 -20
Continue to review full report at Codecov.
|
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 don't need __init__
files inside tests
(pytest will treat it as a packages). Rest LGT
@Larox thank you for the contribution |
@@ -63,7 +65,8 @@ def __init__(self, *args, **kwargs): | |||
|
|||
def iter_errors(self, instance, _schema=None): | |||
if _schema is None: | |||
_schema = self.schema | |||
# creates a copy by value from schema to prevent mutation | |||
_schema = deepcopy(self.schema) |
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 this could be a shallow copy (_schema = self.schema.copy()
), at least for the specific issue that's being addressed by this fix (because we only mutate by adding a new key). That would be a little more memory efficient than a full (deep) object copy.
This PR includes the changes needed to solve issue #24 .
Includes some fixes for tests and unit test for testing the fix included.