Skip to content
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 cache clearing of "attr" attribute on test monkey-patches #558

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/schematools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.data!r})"

def __setitem__(self, key, value):
if key in self.data and key in self.__dict__:
"""Check for changes to the dictionary data. Note this is also called on __init__()."""
if key == "auth" and key in self.data:
logger.warning("auth field is patched by tests")

if (
key in self.__dict__
and (prop := getattr(self.__class__, key, None)) is not None
and isinstance(prop, cached_property)
):
# Clear the @cached_property cache value
del self.__dict__[key]
super().__setitem__(key, value)
Expand Down
Loading