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: decouple the handling of collection length configuration from FieldMeta (Sourcery refactored) #408

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions polyfactory/factories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def get_constrained_field_value(cls, annotation: Any, field_meta: FieldMeta) ->
pattern=constraints.get("pattern"),
)

try:
with suppress(ValueError):
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.get_constrained_field_value refactored with the following changes:

This removes the following comments ( why? ):

# implies the annotation was not a collection type

collection_type = get_collection_type(annotation)
if collection_type == dict:
return handle_constrained_mapping(
Expand All @@ -510,10 +510,6 @@ def get_constrained_field_value(cls, annotation: Any, field_meta: FieldMeta) ->
min_items=constraints.get("min_length"),
unique_items=constraints.get("unique_items", False),
)
except ValueError:
# implies the annotation was not a collection type
pass

if is_safe_subclass(annotation, date):
return handle_constrained_date(
faker=cls.__faker__,
Expand Down