MarcoGorelli / cython-lint

Lint Cython files
MIT License
68 stars 11 forks source link

Failing to pass in paths results in confusing error message #99

Open quattro opened 5 months ago

quattro commented 5 months ago

Hi 👋 , thanks for the great tool! I noticed that failing to pass in a path or paths to cython-lint results in the confusing error,

Traceback (most recent call last):
  File "/Users/nicholas/micromamba/bin/cython-lint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/nicholas/micromamba/lib/python3.11/site-packages/cython_lint/cython_lint.py", line 898, in main
    config = {k.replace('-', '_'): v for k, v in _get_config(paths).items()}
                                                 ^^^^^^^^^^^^^^^^^^
  File "/Users/nicholas/micromamba/lib/python3.11/site-packages/cython_lint/cython_lint.py", line 852, in _get_config
    root = pathlib.Path(os.path.commonpath(paths))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 531, in commonpath
ValueError: commonpath() arg is an empty sequence

I believe a simple remedy for this would be to replace the line

parser.add_argument('paths', nargs='*')

with

parser.add_argument('paths', nargs='+')

This should produce a more helpful error message with users make silly mistakes (like me).

MarcoGorelli commented 5 months ago

Sure, a pr would be welcome thanks