Skip to content
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

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

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

g3n35i5
Copy link
Contributor

@g3n35i5 g3n35i5 commented Apr 6, 2023

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

@g3n35i5 g3n35i5 changed the base branch from master to release-4.2.0 April 6, 2023 06:46
@codecov
Copy link

codecov bot commented Apr 6, 2023

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%) ⬇️

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

@raimon49
Copy link
Owner

raimon49 commented Apr 6, 2023

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
Copy link
Contributor Author

g3n35i5 commented Apr 6, 2023

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
Copy link
Contributor Author

g3n35i5 commented Apr 6, 2023

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
Copy link
Contributor Author

g3n35i5 commented Apr 6, 2023

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

@raimon49 raimon49 mentioned this pull request Apr 8, 2023
@raimon49
Copy link
Owner

raimon49 commented Apr 8, 2023

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
Copy link
Contributor Author

g3n35i5 commented Apr 11, 2023

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.

Copy link
Owner

@raimon49 raimon49 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it's a great approach to be testable with just the function extract_homepage().

The commits also appear to have been combined into one, so we will merge them as they are.

@raimon49 raimon49 merged commit 1133327 into raimon49:release-4.2.0 Apr 12, 2023
@raimon49
Copy link
Owner

@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
Copy link
Contributor Author

g3n35i5 commented Apr 12, 2023

@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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants