Skip to content

Commit

Permalink
Improve docstrings of build/create classmethods
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos authored and francoisfreitag committed Mar 18, 2024
1 parent 1595767 commit dca3a16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions factory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,18 @@ def _create(cls, model_class, *args, **kwargs):

@classmethod
def build(cls, **kwargs) -> T:
"""Build an instance of the associated class, with overridden attrs."""
"""Build an instance of the associated class, with overridden attrs.
The instance will not be saved and persisted to any datastore.
"""
return cls._generate(enums.BUILD_STRATEGY, kwargs)

@classmethod
def build_batch(cls, size: int, **kwargs) -> List[T]:
"""Build a batch of instances of the given class, with overridden attrs.
The instances will not be saved and persisted to any datastore.
Args:
size (int): the number of instances to build
Expand All @@ -527,13 +532,18 @@ def build_batch(cls, size: int, **kwargs) -> List[T]:

@classmethod
def create(cls, **kwargs) -> T:
"""Create an instance of the associated class, with overridden attrs."""
"""Create an instance of the associated class, with overridden attrs.
The instance will be saved and persisted in the appropriate datastore.
"""
return cls._generate(enums.CREATE_STRATEGY, kwargs)

@classmethod
def create_batch(cls, size: int, **kwargs) -> List[T]:
"""Create a batch of instances of the given class, with overridden attrs.
The instances will be saved and persisted in the appropriate datastore.
Args:
size (int): the number of instances to create
Expand Down

0 comments on commit dca3a16

Please sign in to comment.