SoftwareUnderstanding / inspect4py

Static code analysis package for Python repositories
https://inspect4py.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
27 stars 10 forks source link

Requirements extraction (-r) attempts to open non-existent requirements file #381

Closed WilliamsCJ closed 1 year ago

WilliamsCJ commented 1 year ago

When using the -r flag, inspect4py attempts to open the (generally) non-existent requirements file requirements_X.txt, where X is the name of the repository.

Example using pyLODE:

inspect4py -i pyLODE -o pyLODE-out -r

Output:

Traceback (most recent call last):
  File "/Users/cjwilliams/GitHub/inspect4py/inspect4py/utils.py", line 109, in extract_requirements
    with open(file_name, "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements_pyLODE.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/inspect4py/bin/inspect4py", line 33, in <module>
    sys.exit(load_entry_point('inspect4py', 'console_scripts', 'inspect4py')())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/inspect4py/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/inspect4py/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/inspect4py/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/inspect4py/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/cjwilliams/GitHub/inspect4py/inspect4py/cli.py", line 1325, in main
    dir_info["requirements"] = extract_requirements(input_path)
  File "/Users/cjwilliams/GitHub/inspect4py/inspect4py/utils.py", line 125, in extract_requirements
    print("Error finding the requirements in" % input_path)
TypeError: not all arguments converted during string formatting
dgarijo commented 1 year ago

This one is odd! I had tried this one out significantly. Will have to double check.

rosafilgueira commented 1 year ago

@WilliamsCJ I just tested this issue, and with Python 3.9 I dont get any error. See bellow:

inspect4py -i pyLODE -o pyLODE-out -r Creating jsDir:pyLODE-out/pyLODE/json_files Creating jsDir:pyLODE-out/pyLODE/pylode/json_files Creating jsDir:pyLODE-out/pyLODE/pylode/profiles/json_files Creating jsDir:pyLODE-out/pyLODE/tests/json_files Creating jsDir:pyLODE-out/pyLODE/examples/json_files Finding the requirements with the pigar package for pyLODE cmd: echo y | pigar -P pyLODE -p requirements_pyLODE.txt Analysis completed Total number of folders processed (root folder is considered a folder): 5 Total number of files found: 15 Total number of classes found: 4 Total number of dependencies found in those files 201 Total number of functions parsed: 37

rosafilgueira commented 1 year ago

Ok! I got the error with python 3.10 - going to try to solve it

rosafilgueira commented 1 year ago

Now, it should work for both ... 3.9 and 3.10 version. @WilliamsCJ , let us know it works for you! thanks

dgarijo commented 1 year ago

Closing issue, please reopen if required