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

Bug: crash if setup.cfg exists with no metadata section #34

Closed
3 tasks done
nikaro opened this issue Feb 24, 2023 · 2 comments
Closed
3 tasks done

Bug: crash if setup.cfg exists with no metadata section #34

nikaro opened this issue Feb 24, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@nikaro
Copy link

nikaro commented Feb 24, 2023

Bug

  • I have read the comment above and have completed each step
  • I have filled out the system info
  • I have described the bug, filled in the expected outcome and the actual
    outcome including screenshots where appropriate

System info

  • OS: Darwin ***** 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
  • Version: licensecheck==2023.0.1

Describe the bug

It crashes if you have a setup.cfg file that does not contain [metadata] section (for example, with only flake8 configuration).

Expected outcome

List licenses used.

Actual outcome

Traceback (most recent call last):
  File "/Users/nicolas.karolak/Library/Caches/pypoetry/virtualenvs/silvr-app-EZRmeXuX-py3.10/bin/licensecheck", line 8, in <module>
    sys.exit(cli())
  File "/Users/nicolas.karolak/Library/Caches/pypoetry/virtualenvs/silvr-app-EZRmeXuX-py3.10/lib/python3.10/site-packages/licensecheck/__init__.py", line 90, in cli
    depsWithLicenses = get_deps.getDepsWithLicenses(
  File "/Users/nicolas.karolak/Library/Caches/pypoetry/virtualenvs/silvr-app-EZRmeXuX-py3.10/lib/python3.10/site-packages/licensecheck/get_deps.py", line 112, in getDepsWithLicenses
    myLiceTxt = packageinfo.getMyPackageLicense()
  File "/Users/nicolas.karolak/Library/Caches/pypoetry/virtualenvs/silvr-app-EZRmeXuX-py3.10/lib/python3.10/site-packages/licensecheck/packageinfo.py", line 157, in getMyPackageLicense
    metaData = getMyPackageMetadata()
  File "/Users/nicolas.karolak/Library/Caches/pypoetry/virtualenvs/silvr-app-EZRmeXuX-py3.10/lib/python3.10/site-packages/licensecheck/packageinfo.py", line 136, in getMyPackageMetadata
    if "license" in config["metadata"]:
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/configparser.py", line 965, in __getitem__
    raise KeyError(key)
KeyError: 'metadata'
@nikaro nikaro added the bug Something isn't working label Feb 24, 2023
@nikaro
Copy link
Author

nikaro commented Feb 24, 2023

I replaced the line 136 of file licensecheck/packageinfo.py with this and it worked:

if "metadata" in config.sections() and "license" in config["metadata"]:

@FredHappyface
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants