-
Notifications
You must be signed in to change notification settings - Fork 104
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
Simplify suffix_union function #531
Conversation
✅ Deploy Preview for conda-lock ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Attn @jacksmith15 |
14deef0
to
f567e46
Compare
|
||
result: List["SupportsRichComparisonT"] = [] | ||
|
||
def prefix_union(collections: Iterable[Sequence]) -> List: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems an improvement to me!
I wonder if part of the confusion has stemmed from the generic naming of these functions.
Could it be instead called unify_package_sources
or merge_package_sources
?
FWIW the way I reason about this logic is a bit different, not sure if this is more or less confusing to others (probably a tad less performant):
def unify_package_sources(collections: Iterable[Sequence[str]]) -> List[str]:
result = max(collections, key=len)
for collection in collections:
if collection != result[-len(collection):]:
raise ValueError(f"{collection} is not an ordered subset of {result}")
return result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! I think there's an edge case when len(collection) == 0
. But making sure that's in order, would you like to make a PR to supersede mine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to do so 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superseded by #532 |
Description
Closes #530. Let's see if the tests pass...