Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Oct 15, 2023
1 parent b15389b commit a981be1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions polyfactory/factories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,14 @@ def _check_declared_fields_exist_in_model(cls):
for field_name, field_value in factory_fields:
if field_name in model_fields_names or inspect.isfunction(field_value):
continue
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:
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))
warnings.warn(ConfigurationWarning(error_message))


@classmethod
Expand Down

0 comments on commit a981be1

Please sign in to comment.