FHPythonUtils/LicenseCheck

Bug: PEP631 Mode failure: KeyError: 'tool'

connorferster opened this issue · 2 comments

Thank you for creating this tool! I look forward to using it. Hopefully the below bug report is helpful enough for diagnosing.

Before You Begin

Before proceeding, please make sure to follow these steps:

  • I have checked for similar issues in the project's issue tracker.
  • I have searched closed issues to see if a similar problem was reported
    before.

Issue Details

Trying to use licensecheck with a pyproject.toml file generated by flit.

Description

It seems that licensecheck is expecting the existence of optional fields in the pyproject.toml file.

Here is the project that I cloned (and that I want to check): https://github.com/structuralpython/pfse_starterkit

Steps to reproduce:

  1. Create (and activate) new conda environment (mine was with Python 3.10)
  2. Install cloned package (see above)
  3. pip install licensecheck into environment
  4. Navigate to repository root directory (where pyproject.toml lives)
  5. Run licensecheck --using PEP631

Expected Behavior

Expected licensecheck to run

Actual Behavior

(pfse) PS C:\Users\xxxx\xxxx\examples\pfse_starterkit> licensecheck --using PEP631
Traceback (most recent call last):
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\xxxx\miniconda3\envs\pfse\Scripts\licensecheck.exe\__main__.py", line 7, in <module>
    sys.exit(cli())
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\site-packages\licensecheck\__init__.py", line 76, in cli
    configparser.parseConfigList(
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\site-packages\fhconfparser\fhconfparser.py", line 75, in parseConfigList
    dispatchers[conf[1]](
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\site-packages\fhconfparser\fhconfparser.py", line 154, in parseToml
    self.data = {**_resolveNamespace(doc, tomlNamespace), **self.data}
  File "C:\Users\xxxx\miniconda3\envs\pfse\lib\site-packages\fhconfparser\fhconfparser.py", line 341, in _resolveNamespace
    doc = doc[part]
KeyError: 'tool'

System Information

Please provide the following additional information about your system or
environment:

  • Operating System (OS): Windows 10
  • Project Version (if applicable): 2023.5.1

Just checked this out! Yeah I think there's two things here

  1. I've made an assumption that all pyproject.toml s contain a tool table (ngl idk why I did as that seems very silly)
  2. fhconfparser cannot cope when a file exists but not the namespace

So the fix is really needed in that lib

Fixes in latest release :)