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

revert!: revert removed fixes for attrs #974

Merged
merged 4 commits into from Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions interactions/api/models/attrs_utils.py
Expand Up @@ -50,9 +50,23 @@ def __init__(self, kwargs_dict: dict = None, /, **other_kwargs):
if value is not None and attrib.metadata.get("add_client"):
if isinstance(value, list):
for item in value:
item["_client"] = client
if isinstance(item, dict):
item["_client"] = client
elif isinstance(item, DictSerializerMixin):
item._client = client
else:
value["_client"] = client
if isinstance(value, dict):
value["_client"] = client
elif isinstance(value, DictSerializerMixin):
value._client = client

# make sure json is recursively handled
if isinstance(value, list):
self._json[attrib_name] = [
i._json if isinstance(i, DictSerializerMixin) else i for i in value
]
elif isinstance(value, DictSerializerMixin):
self._json[attrib_name] = value._json # type: ignore

passed_kwargs[attrib_name] = value

Expand Down