Skip to content

Commit

Permalink
add docstrings to dataclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
tassaron committed Aug 8, 2023
1 parent da0c5ea commit fa1915e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dnd_character/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

@dataclass(kw_only=True, frozen=True, slots=True)
class _CLASS:
"""
Dataclass for (D&D 5e) classes. Classes are suggested to be constants. (Immutable.)
So deserialization shouldn't be necessary, but is possible with _CLASS(**dict).
Or get the constant version from `dnd_character.classes.CLASSES[class_name]`
"""

index: str
name: str
url: str
Expand Down
2 changes: 2 additions & 0 deletions dnd_character/equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@dataclass(kw_only=True)
class _Item:
"""Dataclass for items. Deserialize item with `_Item(**dict)` or Item() function"""

uid: str = uuid4().hex
contents: list[dict[str, Union[int, dict[str, str]]]]
cost: dict[str, Union[str, int]]
Expand Down
2 changes: 2 additions & 0 deletions dnd_character/monsters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@dataclass(kw_only=True)
class _Monster:
"""Dataclass for items. Deserialize item with `_Monster(**dict)` or Monster() function"""

index: str
uid: str = uuid4().hex
type: str
Expand Down
6 changes: 6 additions & 0 deletions dnd_character/spellcasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

@dataclass(kw_only=True, frozen=True, slots=True)
class _SPELL:
"""
Dataclass for spells. Spells are suggested to be constants. (Immutable.)
So deserialization shouldn't be necessary, but is possible with _SPELL(**dict).
Or get the constant version from `dnd_character.spellcasting.SPELLS[spell_name]`
"""

area_of_effect: Optional[dict[str, Union[str, int]]] = None
attack_type: Optional[str] = None
casting_time: str
Expand Down

0 comments on commit fa1915e

Please sign in to comment.