Skip to content

Commit

Permalink
fixup! feat: Better support for dataclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 29, 2024
1 parent 733b326 commit f51c37b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/griffe/extensions/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,8 @@ def _reorder_parameters(parameters: list[Parameter]) -> list[Parameter]:


def _set_dataclass_init(class_: Class) -> None:
parameters = []

# If the class already has an `__init__` method, skip it.
if "__init__" in class_.members:
return

# Retrieve parameters from all parent dataclasses.
parameters = []
try:
mro = class_.mro()
except ValueError:
Expand Down Expand Up @@ -182,7 +177,8 @@ def _apply_recursively(mod_cls: Module | Class, processed: set[str]) -> None:
return
processed.add(mod_cls.canonical_path)
if isinstance(mod_cls, Class):
_set_dataclass_init(mod_cls)
if "__init__" not in mod_cls.members:
_set_dataclass_init(mod_cls)
for member in mod_cls.members.values():
if not member.is_alias and member.is_class:
_apply_recursively(member, processed) # type: ignore[arg-type]
Expand Down

0 comments on commit f51c37b

Please sign in to comment.