Skip to content
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

Lint/Format/Fix failed - error: Ruff crashed, with lines starting with non-Latin characters in jupyter notebook #369

Closed
lethefrost opened this issue Dec 17, 2023 · 2 comments

Comments

@lethefrost
Copy link

In jupyter notebook, ruff keeps crashing when you have any line (in code cell) starting with a non-Latin character. Those characters in the middle of a line or as trailing characters doesn't trigger this bug.

To be specific, I have tested with Chinese, Japanese, Korean, Hindi, and they all lead to this issue. I have also tested French, Spanish, Italian (with accented characters), German, Arabic, and Russian, and they survive from crashing. (I believe Arabic, Russian, and German are not Latin languages though. There must be some bug against Asian characters 😂😂)

The use case of lines starting with other languages mainly happens in dosctrings, but some people also use their mother languages to name variables. Therefore, it's a rather common thing to expect in a notebook.

The error message is as the following:

thread 'main' panicked at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/str/mod.rs:660:13:
byte index 2 is not a char boundary; it is inside '<the buggy char>' (bytes 0..3) of `<the buggy line>`

Here is a test example with some Chinese characters for your convenience to reproduce this bug:

def test():
    """测试 <- the line starts with " so the chinese character dosen't trigger the bug
    测试 <- this line starts with 测, and should cause ruff to crash
    """
    pass

I am working on macOS 14.2, VSC 1.85.1, Python 3.12.0, jupyter_core 5.5.0, Ruff v2023.58.0.

Thank you for your efforts!

@konstin
Copy link
Member

konstin commented Dec 17, 2023

I think this same bug as fixed in astral-sh/ruff#9146

@lethefrost
Copy link
Author

I think this same bug as fixed in astral-sh/ruff#9146

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants