Skip to content

Commit

Permalink
Remove the deprecated use_strategy helper
Browse files Browse the repository at this point in the history
Deprecated since 2020, users have had ample warning.
  • Loading branch information
francoisfreitag committed Aug 27, 2024
1 parent 0f1a344 commit 1bd9521
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 35 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ChangeLog

The transitional setting :attr:`factory.django.DjangoOptions.skip_postgeneration_save` can be removed.

- :func:`factory.use_strategy`. Use :attr:`factory.FactoryOptions.strategy` instead.

3.3.1 (2024-08-18)
------------------
Expand Down
17 changes: 0 additions & 17 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -579,23 +579,6 @@ factory_boy supports two main strategies for generating instances, plus stubs.
>>> return obj
.. function:: use_strategy(strategy)

.. deprecated:: 3.2

Use :py:attr:`factory.FactoryOptions.strategy` instead.

*Decorator*

Change the default strategy of the decorated :class:`Factory` to the chosen ``strategy``:

.. code-block:: python
@use_strategy(factory.BUILD_STRATEGY)
class UserBuildingFactory(UserFactory):
pass
.. data:: STUB_STRATEGY

The 'stub' strategy is an exception in the factory_boy world: it doesn't return
Expand Down
1 change: 0 additions & 1 deletion factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Factory,
ListFactory,
StubFactory,
use_strategy,
)
from .declarations import (
ContainerAttribute,
Expand Down
17 changes: 0 additions & 17 deletions factory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,20 +727,3 @@ def _create(cls, model_class, *args, **kwargs):
class ListFactory(BaseListFactory):
class Meta:
model = list


def use_strategy(new_strategy):
"""Force the use of a different strategy.
This is an alternative to setting default_strategy in the class definition.
"""
warnings.warn(
"use_strategy() is deprecated and will be removed in the future.",
DeprecationWarning,
stacklevel=2,
)

def wrapped_class(klass):
klass._meta.strategy = new_strategy
return klass
return wrapped_class

0 comments on commit 1bd9521

Please sign in to comment.