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] Consistent return statements #37

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion oscar_odin/mappings/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def products_to_db(
After that all the products will be bulk saved.
At last all related models like images, stockrecords, and related_products can will be saved and set on the product.
"""
errors = validate_resources(products)
_, errors = validate_resources(products)
if errors:
return [], errors
instances, context = products_to_model(
Expand Down
6 changes: 4 additions & 2 deletions oscar_odin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ def querycounter(*labels, print_queries=False):

def validate_resources(resources):
errors = []
valid_resources = []
if not resources:
return
return [], []
if not isinstance(resources, (list, tuple)):
if isinstance(resources, MappingResult):
resources = resources.items
Expand All @@ -87,6 +88,7 @@ def validate_resources(resources):
for resource in resources:
try:
resource.full_clean()
valid_resources.append(resource)
except ValidationError as error:
errors.append(error)
return errors
return valid_resources, errors
Loading