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

Check if fields declared on the factory belong to the model (Sourcery refactored) #406

Closed
wants to merge 3 commits into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 13, 2023

Pull Request #405 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/litestar-org/polyfactory pull/405/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested review from a team as code owners October 13, 2023 14:40
@sourcery-ai sourcery-ai bot changed the title [DRAFT] Check if fields declared on the factory belong to the model (Sourcery refactored) Check if fields declared on the factory belong to the model (Sourcery refactored) Oct 15, 2023
Comment on lines +688 to +695
error_message = (
f"{field_name} is declared on the factory {cls.__name__}"
f" but it is not part of the model {cls.__model__.__name__}"
)
if isinstance(field_value, (Use, PostGenerated, Ignore, Require)):
raise ConfigurationException(error_message)
else:
warnings.warn(ConfigurationWarning(error_message))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BaseFactory._check_declared_fields_exist_in_model refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants