raimon49 / pip-licenses

Dump the license list of packages installed with pip.
MIT License
298 stars 42 forks source link

feat: Use `Project-URL` metadata as fallback if `home-page` is None #155

Closed g3n35i5 closed 1 year ago

g3n35i5 commented 1 year ago

Hello again!

This PR basically cleans up my last fallback solution with a slightly more cleaner way to get the values from the metadata by using (type annotated) lambda functions and uses the first Project-URL value of the metadata.

Current output:

Name       Version  License      Author                                       URL     
termcolor  2.2.0    MIT License  Konstantin Lepa <konstantin.lepa@gmail.com>  UNKNOWN

New output:

Name            Version  License      Author                                      URL  
termcolor       2.2.0    MIT License  Konstantin Lepa <konstantin.lepa@gmail.com> https://github.com/termcolor/termcolor
codecov[bot] commented 1 year ago

Codecov Report

Merging #155 (8e04928) into release-4.2.0 (bacc2ee) will decrease coverage by 0.22%. The diff coverage is 88.88%.

@@                Coverage Diff                @@
##           release-4.2.0     #155      +/-   ##
=================================================
- Coverage          99.51%   99.29%   -0.22%     
=================================================
  Files                  1        1              
  Lines                414      427      +13     
=================================================
+ Hits                 412      424      +12     
- Misses                 2        3       +1     
Impacted Files Coverage Δ
piplicenses.py 99.29% <88.88%> (-0.22%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

raimon49 commented 1 year ago

The type check for python 3.11 fails but I don't know why: package.metadata is of type Message according to the docu. Do you know why this fails?

Contributors other than myself introduced the type checking, for example, the following versioned code exists in test_piplicenses.py :

if TYPE_CHECKING:
    if sys.version_info >= (3, 10):
        from importlib.metadata._meta import PackageMetadata
    else:
        from email.message import Message as PackageMetadata
g3n35i5 commented 1 year ago

The type check for python 3.11 fails but I don't know why: package.metadata is of type Message according to the docu. Do you know why this fails?

Contributors other than myself introduced the type checking, for example, the following versioned code exists in test_piplicenses.py :

if TYPE_CHECKING:
    if sys.version_info >= (3, 10):
        from importlib.metadata._meta import PackageMetadata
    else:
        from email.message import Message as PackageMetadata

Thanks! I fixed the type and also improved the url extraction.

g3n35i5 commented 1 year ago

Somehow, black doesn't work with the make lint in my environment, sorry for that. If you merge the PR, please use a squash commit in order to reduce the number of commits.

g3n35i5 commented 1 year ago

Okay the type annotations are still not correct. I'll fix this after the weekend.

raimon49 commented 1 year ago

I am very sorry, I merged another PR and release-4.2.0 was rebased.

Your working branch, fallback-for-url branch, also needs to be rebase to release-4.2.0.

g3n35i5 commented 1 year ago

I am very sorry, I merged another PR and release-4.2.0 was rebased.

Your working branch, fallback-for-url branch, also needs to be rebase to release-4.2.0.

No worries. I rebased the PR and fixed the type issues.

raimon49 commented 1 year ago

@g3n35i5 I have created a release candidate version merging this PR.

Could you please confirm that it is working as you intended?

pip install "pip-licenses==4.2.0rc3"

If there are no problems, I will proceed to a production release.

g3n35i5 commented 1 year ago

@g3n35i5 I have created a release candidate version merging this PR.

Could you please confirm that it is working as you intended?

pip install "pip-licenses==4.2.0rc3"

If there are no problems, I will proceed to a production release.

Thanks! 4.2.0rc3 works as expected in my setup :+1: