Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set as default type for factory only if model is defined #479

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

guacs
Copy link
Member

@guacs guacs commented Jan 11, 2024

Description

When __set_as_default_factory_for_type__ is set tot True, we try to access the __model__ in order to map the type to the factory. However, in base factories, the 'model' will not be defined and so it an 'AttributeError' will be raised when trying to access 'cls.model'. So, we simply ensure that 'model' defined before trying to access it.

Close Issue(s)

In base factories, the '__model__' will not be defined and so it an 'AttributeError' will be raised when trying to
access 'cls.__model__'. So we simply ensure that '__model__' defined before trying to access it.
Copy link

sonarcloud bot commented Jan 14, 2024

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/polyfactory-docs-preview/479

@guacs guacs merged commit 40538c9 into main Jan 16, 2024
20 checks passed
@guacs guacs deleted the set-as-default-factory-for-type branch January 16, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: settings __set_as_default_factory_for_type__ to True on base factory fails
2 participants