-
-
Notifications
You must be signed in to change notification settings - Fork 38
Fix duplicate best_compatible_tag_index call #251
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
Conversation
micropip/transaction.py
Outdated
| tag_index = wheel._best_tag_index | ||
| if tag_index is None: | ||
| tag_index = best_compatible_tag_index(wheel.tags) | ||
| wheel._best_tag_index = tag_index |
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.
I think it is not a good idea to update the the private attribute of an object outside.
Instead, we can create a property in WheelInfo object such as
@property
def best_tag_index(self) -> float:
if self._best_tag_index:
return self._best_tag_index
self._best_tag_index = best_compatible_tag_index(self.tags)
return self._best_tag_index
micropip/package_index.py
Outdated
| try: | ||
| tags = parse_tags(filename) | ||
| except (InvalidVersion, InvalidWheelFilename): | ||
| continue | ||
|
|
||
| tag_index = best_compatible_tag_index(tags) | ||
| if tag_index is None: | ||
| continue |
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.
Well, is_package_compatible does more than this.
I think we can keep the is_package_compatible call here, and update the signature of is_package_compatible to return the compatible tag as well.
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.
Done, thank you
ryanking13
left a comment
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.
Thanks!
This computes tag index once, then stash it to wheel._best_tag_index.
Closes #160.