Buckets:

download
raw
745 Bytes
def remove_fields(obj: dict | list | tuple, fields: set[str]) -> None:
"""Remove fields from an object.
Parameters:
- obj: The dictionary, or list of dictionaries to remove fields from
- fields (set[str]): A set of field names to remove from the object
"""
if isinstance(obj, dict):
for field in fields:
if field in obj:
del obj[field]
for _, value in obj.items():
remove_fields(value, fields)
elif isinstance(obj, (list, tuple)):
for item in obj:
remove_fields(item, fields)
if hasattr(obj, '__dataclass_fields__'):
raise ValueError(
'Object must not contain dataclass, consider converting to dict first'
)

Xet Storage Details

Size:
745 Bytes
·
Xet hash:
be926e24f68e5318b0b4af53b2239d0a128092e73437f90fc979e2f4a3582dc5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.