-
-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isort --atomic fails on Cython "cimport" syntax #1722
Comments
Hi @DanielFEvans, Sorry you experienced this error! I could see how it could be jarring! It is correct that atomic is incomptible with Cython, but that is simply because atomic is based fully on the ability to parse it after sorting with the CPython AST. I think expanding support to Cython as well would be awesome! |
Is it possible to enable atomic for normal Python and simultaneously disable it for Cython files? I've not spotted any configurability like that, but there are a lot of options! |
It seems unlikely that Cython will in short order expose an AST parsing API so in the meantime, Ive improved the behavior to warn in verbose mode instead of fail when a Cython exentioned file contains a Python AST error. Hopefully, at some point in the future, Cython files will also be able to fully be checked for ast errors. |
With v5.9.1, I still see this error if I use the $ isort --atomic --check-only buggy.pyx
ERROR: isort was told to sort imports within code that contains syntax errors: .../buggy.pyx. Is this intentional? |
@JohnHBrock no it is not intentional! I have pushed an change to fix this to the main branch, and plan to push a new release to PyPI sometime over the next week. |
isort --atomic
fails for any Cython .pyx file containing acimport
statement, claiming it has an existing syntax error. A minimal example is:isort buggy.pyx --diff
runs fine:However,
isort buggy.pyx --diff --atomic
fails:Bug found on isort v5.8.0, but the bug exists as far back as isort v5.0.0, when Cython support was added.
I presume the same issue will occur for any other Cython-specific syntax, too.
The text was updated successfully, but these errors were encountered: