Skip to content

Commit fcfc05b

Browse files
author
Sylvain MARIE
committed
@autoclass now removes private fields from the generated autodict representation by default. Fixes #37
1 parent e92dff8 commit fcfc05b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

autoclass/autoclass_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ class has `pyfields` fields and does not define an `__init__` method ; and `Fals
205205
raise ValueError("`autoeq` can not be set to `True` simultaneously with `autodict`. Please set "
206206
"`autodict=False`.")
207207
# By default execute with the known list of fields, so equivalent of `only_known_fields=True`.
208-
execute_autodict_on_class(cls, selected_names=selected_names)
208+
# Exclude private fields by default to have a consistent behaviour with autodict
209+
public_names = tuple(n for n in selected_names if not n.startswith('_'))
210+
execute_autodict_on_class(cls, selected_names=public_names)
209211
else:
210212
if autorepr is AUTO or autorepr:
211213
# By default execute with the known list of fields, so equivalent of `only_known_fields=True`.

0 commit comments

Comments
 (0)