MarcoGorelli / cython-lint

Lint Cython files
MIT License
68 stars 11 forks source link

feat: Support configuration in .cython-lint.toml #104

Closed dalcinl closed 4 months ago

dalcinl commented 4 months ago

Fixes #84.

cc @webknjaz

dalcinl commented 4 months ago

@MarcoGorelli Any estimate for an upcoming release with this feature?

MarcoGorelli commented 4 months ago

hey @dalcinl , I just pushed one out, does it work for you?

dalcinl commented 4 months ago

Yes, it works perfectly!

There is a minor nit, though, unrelated to this PR.

Calling cython-lint without arguments fail with traceback

$ cython-lint
Traceback (most recent call last):
  File "/home/dalcinl/.local/bin/cython-lint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/dalcinl/.local/lib/python3.12/site-packages/cython_lint/cython_lint.py", line 930, in main
    config = {k.replace("-", "_"): v for k, v in _get_config(paths).items()}
                                                 ^^^^^^^^^^^^^^^^^^
  File "/home/dalcinl/.local/lib/python3.12/site-packages/cython_lint/cython_lint.py", line 880, in _get_config
    root = pathlib.Path(os.path.commonpath(paths))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 550, in commonpath
ValueError: commonpath() arg is an empty sequence

This should either print usage and exit with error code, or maybe better make it equivalent to cython-lint ., that is, lint recursively from the current working directory. Let me know your preference and I'll submit a PR, together with support for running with python -m cython_lint <args>.

MarcoGorelli commented 4 months ago

print usage and exit with error code

Sounds good

dalcinl commented 4 months ago

lint recursively from the current working directory

So, don't you like this other alternative? It is the behavior of ruff check and flake8. But you have no attachment to behavioral consistency with flake8, that's fine with me. I'm just trying to point out the rationale for the alternative.