Handle invalid requirement strings when using importlib.metadata#345
Merged
gaborbernat merged 3 commits intotox-dev:mainfrom Apr 6, 2024
Merged
Handle invalid requirement strings when using importlib.metadata#345gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat merged 3 commits intotox-dev:mainfrom
Conversation
kemzeb
commented
Apr 5, 2024
Comment on lines
+18
to
+28
| def render_invalid_reqs_text_if_necessary(dist_name_to_invalid_reqs_dict: dict[str, list[str]]) -> None: | ||
| if not dist_name_to_invalid_reqs_dict: | ||
| return | ||
|
|
||
| print("Warning!!! Invalid requirement strings found for the following distributions:", file=sys.stderr) # noqa: T201 | ||
| for dist_name, invalid_reqs in dist_name_to_invalid_reqs_dict.items(): | ||
| print(dist_name, file=sys.stderr) # noqa: T201 | ||
|
|
||
| for invalid_req in invalid_reqs: | ||
| print(f' Skipping "{invalid_req}"', file=sys.stderr) # noqa: T201 | ||
| print("-" * 72, file=sys.stderr) # noqa: T201 |
Collaborator
Author
There was a problem hiding this comment.
I feel like we have been duplicating the print warning logic across quite a few areas of the codebase. I think we should ponder a better way of handling this in the future
gaborbernat
requested changes
Apr 5, 2024
Collaborator
Author
|
Here's an example of what it looks like: $ pipdeptree
Warning!!! Invalid requirement strings found for the following distributions:
catalyst
Skipping "scikit-image (<0.19.0>=0.16.1) ; extra == 'all'"
------------------------------------------------------------------------
catalyst==22.4
├── accelerate [required: >=0.5.1, installed: 0.29.1]
│ ├── huggingface-hub [required: Any, installed: 0.22.2]
│ │ ├── filelock [required: Any, installed: 3.13.3]
. . . |
gaborbernat
approved these changes
Apr 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #344.
This change also:
Distribution.requires()into a generator for performance (i.e. avoid buildinglist[Requirement]and then iteratinglist[Requirementand instead do both at the same time) and so that we can handle invalid requirement exceptions inPackageDAG.from_pkgs()for each individual requirement string