-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Draft licenses CLI feature #1433
Conversation
Codecov ReportBase: 84.97% // Head: 85.11% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1433 +/- ##
==========================================
+ Coverage 84.97% 85.11% +0.14%
==========================================
Files 88 88
Lines 7662 7836 +174
Branches 1798 1852 +54
==========================================
+ Hits 6511 6670 +159
- Misses 766 779 +13
- Partials 385 387 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The output is very similar to |
@frostming sounds good to me, but it will impact other functions inside pdm like Shall I keep the switches for selecting fields, skipping dep groups, changing the sort column, etc? EDIT: It could also live in a plugin - happy to follow your guidance and suggestions from others. |
The column selection is great, let's revisit the current options and the options to be added, if it is to be integrated in to
I hope that doesn't make the feature too complex. Footnotes |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
I had another quick go at this again to match your feature matrix, let me know what you think! Let me know if I missed anything or you would like something to be done differently. Questions:
If you are happy, I can make some test cases. |
The current implementation LGTM.
Two options, 1) use a special identifier to avoid conflicting with existing groups, such as
IMO it is okay to ignore the entries with extras |
For example: def test_list_command(project, invoke, mocker): # previous test
do_list = mocker.patch.object(actions, "do_list")
invoke(["list"], obj=project)
do_list.assert_called_once() # <--- works OK in old codebase
def test_list_command(project, invoke, mocker): # proposed new test
handle = mocker.patch.object(Command, "handle")
invoke(["list"], obj=project)
handle.assert_called_once() # <--- list.Command.handle is not called |
Yeah, that is the markup syntax of rich console,
These tests around P.S. I've converted this PR to draft, until it is ready to review. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Added a few of comments on the code where I need some help/advice about what the correct behaviour should be. Thanks! |
tests/cli/test_list.py
Outdated
# # matches the environment or hashes\nAdd '-v' to see the detailed traceback\n" | ||
# @pytest.mark.usefixtures("working_set", "repository") | ||
# def test_list_bare_sorted_version_resolve(project, invoke, repository): | ||
# # project.environment.python_requires = PySpecSet(">=3.6") |
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.
You need to mock the .metadata
(or .prepare_metadata()
) cuz it will be accessed during the command, which will try to find a package link and fail.
pdm/src/pdm/cli/commands/list.py
Lines 144 to 146 in cd2f1a9
resolved_set = set( | |
c.prepare(project.environment).metadata for c in candidates.values() | |
) |
@JohnHardy Thanks for the contribution, it may still need to be refined. I will merge it first and continue the work on another branch. |
Fantastic, thank you for making last refinements. I look forward to seeing the changes - please ping me if I can help in the future👍 |
Pull Request Check List
news/
describing what is new.Describe what you have changed in this PR.
Added a new CLI command
licenses
that allows you to output the license documentation for all the deps. This usually requires 3rd party projects that may or may not be compatible with whatever packaging system is used. This CLI command implements common use cases that I have seen in the wild.🙏🙏 If you are interested in merging this PR in, please let me know so I will invest the time to lint / write test cases. However, before that, I wanted to make sure that you were happy with: (1) the existence of the feature, (2) the implementation details, my first time working on a package manager, (3) the ux. 🙏🙏
Features are:
License
field is empty, it will try to recover it from the Trove classifiers.Here are some use cases:
pdm licenses
pdm licenses --resolve --skip default,tox,workflow,sub --fields group,identifier,version,licenses --sort licenses
pdm licenses --sort licenses
pdm licenses --sort licenses --csv
pdm licenses --sort licenses --markdown > mylicenses.md