pyre2 icon indicating copy to clipboard operation
pyre2 copied to clipboard

flake8 and coverage.py syntax errors

Open sarnold opened this issue 2 years ago • 3 comments

eg:

src/re2.pyx:106:9: E999 SyntaxError: invalid syntax

This didn't happen with older flake8 versions; the coverage thing is new. There are some issue/so discussions about cython and coverage.py and projects using the src/ layout. That last bit is usually src/<name> and isn't (by itself) a problem, except the cython coverage plugin apparently gets confused with includes and src/ without any __init__.py etc. :/

I'll keep looking but for now coverage is not working and flake8 config has E999 added to ignore list.

sarnold avatar Dec 16 '22 00:12 sarnold

Update 1:

Turns out flake8 was an upstream red-herring since version 4 stops doing anything if the AST check fails, thus the (new) E999 warning and no additional output. Falling back to flake8<4 produces the expected indenting and other misc warnings. Sadly there is no official support for linting cython source that I know of, at least from the flake8 authors.

Update 2:

Although the latest cython (pre) releases do claim coverage support for src/ package layout, coverage.py and/or the cython.coverage plugin are still broken on the includes in this project. I still need to file an upstream bug and test an idea or two (pending feedback on the bug).

sarnold avatar Dec 19 '22 02:12 sarnold

re update 2: if it makes life easier, let's rename src to re2 ? these tools expect the directory to have the same name as the module, right? Or is a package required as well?

andreasvc avatar Dec 20 '22 16:12 andreasvc

Sadly there is no official support for linting cython source that I know of, at least from the flake8 authors.

Sorry for the self-promo, but may I suggest trying out cython-lint? It parses the Cython AST directly, and implements many of the same checks

MarcoGorelli avatar Dec 23 '22 15:12 MarcoGorelli