litestar-org / polyfactory

Simple and powerful factories for mock data generation
https://polyfactory.litestar.dev/
MIT License
1k stars 78 forks source link

Bug: settings `__set_as_default_factory_for_type__ ` to `True` on base factory fails #476

Closed guacs closed 8 months ago

guacs commented 8 months ago

Description

If __set_as_default_factory_for_type__ is set to True on a custom base factory so that all the subclasses factories inherit that value, then an AttributeError is raised.

URL to code causing the issue

No response

MCVE

from polyfactory.factories import DataclassFactory
from polyfactory.factories.base import T

class CustomDataclassBaseFactory(DataclassFactory[T]):
    __is_base_factory__ = True
    __set_as_default_factory_for_type__ = True

Steps to reproduce

Run the MCVE.

Screenshots

No response

Logs

No response

Release Version

2.13.0

Platform


[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.

Fund with Polar