Skip to content

Commit

Permalink
fix(generic): filter the iterator before returning the first element
Browse files Browse the repository at this point in the history
... this way it returns the nth element if the first n-1 ones are
False - which it should have done in the first place, instead of
returning False if only the nth element is actually a class
  • Loading branch information
b1rger committed Jan 19, 2024
1 parent 7ad2662 commit a6fba0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apis_core/generic/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ def first_match_via_mro(model, path: str = "", suffix: str = ""):
"""
paths = list(map(lambda x: x[:-1] + [path] + x[-1:], mro_paths(model)))
classes = [".".join(prefix) + suffix for prefix in paths]
return next(map(class_from_path, classes), None)
return next(filter(bool, map(class_from_path, classes)), None)

0 comments on commit a6fba0f

Please sign in to comment.