Skip to content

Commit

Permalink
refactor: Add repr methods to function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Sep 28, 2023
1 parent 039a702 commit 9442234
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/griffe/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def __str__(self) -> str:
return f"[{self.kind.value}] {param}"
return param

def __repr__(self) -> str:
return f"Parameter(name={self.name!r}, annotation={self.annotation!r}, kind={self.kind!r}, default={self.default!r})"

@property
def required(self) -> bool:
"""Whether this parameter is required."""
Expand Down Expand Up @@ -237,6 +240,9 @@ def __init__(self, *parameters: Parameter) -> None:
for parameter in parameters:
self.add(parameter)

def __repr__(self) -> str:
return f"Parameters({', '.join(repr(param) for param in self._parameters_list)})"

def __getitem__(self, name_or_index: int | str) -> Parameter:
if isinstance(name_or_index, int):
return self._parameters_list[name_or_index]
Expand Down

0 comments on commit 9442234

Please # to comment.