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

Have --license work with --reverse #321

Merged
merged 1 commit into from
Feb 24, 2024
Merged

Conversation

kemzeb
Copy link
Collaborator

@kemzeb kemzeb commented Feb 24, 2024

In #318 I did not consider the case where users would pass --reverse along with --license. Currently, doing so would have us output the following:

$ pipdeptree --reverse --license -d 1
chardet==5.2.0
└── diff-cover==8.0.3 [requires: chardet>=3.0.0] (Apache Software License)
coverage==7.4.2
├── covdefaults==2.3.0 [requires: coverage>=6.0.2] (MIT License)
└── pytest-cov==4.1.0 [requires: coverage>=5.2.1] (MIT License)
distlib==0.3.8
└── virtualenv==20.25.1 [requires: distlib>=0.3.7,<1] (MIT License)
exceptiongroup==1.2.0
└── pytest==8.0.1 [requires: exceptiongroup>=1.0.0rc8] (MIT License)
filelock==3.13.1
└── virtualenv==20.25.1 [requires: filelock>=3.12.2,<4] (MIT License)
iniconfig==2.0.0
└── pytest==8.0.1 [requires: iniconfig] (MIT License)
MarkupSafe==2.1.5
└── Jinja2==3.1.3 [requires: MarkupSafe>=2.0] (BSD License)
packaging==23.2
└── pytest==8.0.1 [requires: packaging] (MIT License)
pip==24.0
pipdeptree==0.1.dev418+gc6de3c3
. . . .

As it's shown, the required packages (i.e. graph nodes that were instances of DistPackage) are given their license when the top-level packages should have been given theirs instead. This PR addresses this text render issue by appending the license to a package only if it's a top-level package (instead of just checking to see if node is an instance of DistPackage).

The output with my changes:

$ pipdeptree --reverse --license -d 1
chardet==5.2.0 (GNU Lesser General Public License v2 or later (LGPLv2+))
└── diff-cover==8.0.3 [requires: chardet>=3.0.0]
coverage==7.4.2 (Apache Software License)
├── covdefaults==2.3.0 [requires: coverage>=6.0.2]
└── pytest-cov==4.1.0 [requires: coverage>=5.2.1]
distlib==0.3.8 (Python Software Foundation License)
└── virtualenv==20.25.1 [requires: distlib>=0.3.7,<1]
exceptiongroup==1.2.0 (MIT License)
└── pytest==8.0.1 [requires: exceptiongroup>=1.0.0rc8]
filelock==3.13.1 (The Unlicense (Unlicense))
└── virtualenv==20.25.1 [requires: filelock>=3.12.2,<4]
iniconfig==2.0.0 (MIT License)
└── pytest==8.0.1 [requires: iniconfig]
MarkupSafe==2.1.5 (BSD License)
└── Jinja2==3.1.3 [requires: MarkupSafe>=2.0]
packaging==23.2 (Apache Software License, BSD License)
└── pytest==8.0.1 [requires: packaging]
pip==24.0 (MIT License)
pipdeptree==0.1.dev418+gc6de3c3 (MIT License)
. . . .

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat merged commit bc804e3 into tox-dev:main Feb 24, 2024
10 checks passed
@kemzeb kemzeb deleted the fix-license branch February 24, 2024 03:11
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