MarcoGorelli / cython-lint

Lint Cython files
MIT License
69 stars 11 forks source link

Cannot parse compile-time definitions #56

Closed stefanv closed 1 year ago

stefanv commented 1 year ago

See https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#compile-time-definitions

Input:

DEF NFEATURES_CUTOFF = 5

Output:

cant parse scipy/cluster/_vq.pyx: AttributeError("'_thread._local' object has no attribute 'cython_errors_listing_file'")
MarcoGorelli commented 1 year ago

I can't reproduce this:

(.venv) marcogorelli@DESKTOP-U8OKFP3:~/cython-lint-dev$ cat t.pyx
DEF NFEATURES_CUTOFF = 5
(.venv) marcogorelli@DESKTOP-U8OKFP3:~/cython-lint-dev$ cython-lint t.pyx

Is that the whole file?

MarcoGorelli commented 1 year ago

🤔 can't reproduce with the file you mentioned either

(.venv) marcogorelli@DESKTOP-U8OKFP3:~/cython-lint-dev$ cp ../scipy-dev/scipy/cluster/_vq.pyx t.pyx
(.venv) marcogorelli@DESKTOP-U8OKFP3:~/cython-lint-dev$ cython-lint t.pyx
t.pyx:54:16: E127 continuation line over-indented for visual indent
t.pyx:124:21: E128 continuation line under-indented for visual indent
stefanv commented 1 year ago
$ cython-lint --version
0.12.3
(py310) $ cython-lint /tmp/_vq.pyx
Skipping file /tmp/_vq.pyx, as it cannot be parsed. Error: AttributeError("'_thread._local' object has no attribute 'cython_errors_listing_file'")
(py310) $ cat /tmp/_vq.pyx
DEF NFEATURES_CUTOFF = 5
MarcoGorelli commented 1 year ago

Thanks - which version of Cython?

MarcoGorelli commented 1 year ago

🤔 really not sure what to do here if I can't reproduce it

(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ python --version
Python 3.11.1
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ cython-lint --version
0.12.3
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ cat t.pyx
DEF NFEATURES_CUTOFF = 5
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ cython-lint t.pyx
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ echo $?
0
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/tmp$ python -c 'import cython; print(cython.__version__)'
0.29.33
stefanv commented 1 year ago

That might be it!

Cython version 3.0.0a11

MarcoGorelli commented 1 year ago

thanks again for the report! new version shipped