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

Ruff: Lint failed (error: Ruff crashed) #362

Closed
Fissium opened this issue Dec 14, 2023 · 9 comments · Fixed by astral-sh/ruff#9146
Closed

Ruff: Lint failed (error: Ruff crashed) #362

Fissium opened this issue Dec 14, 2023 · 9 comments · Fixed by astral-sh/ruff#9146
Labels
bug Something isn't working

Comments

@Fissium
Copy link

Fissium commented Dec 14, 2023

I just upgraded to the latest version from v2023.50.0 and got the following error:

Ruff: Lint failed (
error: Ruff crashed. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BPanic%5D

...quoting the executed command, along with the relevant file contents and `pyproject.toml` settings, we'd be very appreciative!

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 'Т' (bytes 1..3) of `"Ты`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
)

The error is related to these lines of code:

DEFAULT_SYSTEM_PROMPT = (
    "Ты — Сайга, русскоязычный автоматический ассистент. "
    "Ты разговариваешь с людьми и помогаешь им."
)

My settings.json

{
    "window.titleBarStyle": "custom",
    "workbench.startupEditor": "none",
    "extensions.autoUpdate": false,
    "explorer.confirmDragAndDrop": false,
    "ruff.importStrategy": "useBundled",
    "editor.fontFamily": "Fira Code",
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.fontLigatures": true,
    "files.watcherExclude": {
	    "**/.venv": true
    },
    "files.exclude": {
	    "**/.venv": true
    },
    "python.analysis.typeCheckingMode": "basic",
    "python.analysis.diagnosticMode": "openFilesOnly",
    "python.analysis.diagnosticSeverityOverrides": {
	    "reportUnusedImport": "none",
	    "reportUnusedVariable": "none",
	    "reportUndefinedVariable": "none",
	    "reportUnusedClass": "none",
	    "reportUnusedExpression": "none",
	    "reportUnusedFunction": "none",
    },
    "ruff.lint.args": [
	    "--select=ARG",
	    "--select=F",
	    "--select=E",
	    "--select=I001",
    ],
}

VS Code extension versions - v2023.54.0

Environment:
OS: Archlinux
Python: 3.11 (conda env)

@charliermarsh
Copy link
Member

Thank you!

@charliermarsh charliermarsh added the bug Something isn't working label Dec 14, 2023
@dhruvmanila
Copy link
Member

I'm unable to reproduce this on MacOS with the following command:

pipx run "ruff==0.1.5" check --select=I,E,F,ARG --no-cache --isolated src/play.py --preview --unsafe-fixes --fix --diff

The extension version v2023.50.0 ships with Ruff v0.1.5.

@charliermarsh
Copy link
Member

@dhruvmanila - It looks like they're using latest (they upgraded from v2023.50.0).

@dhruvmanila
Copy link
Member

Oh sorry, I misread the first line. Still unable to reproduce with v0.1.8 :(

@Fissium
Copy link
Author

Fissium commented Dec 14, 2023

@dhruvmanila on macOS, I see the following in the logs:

OSError: [Errno 86] Bad CPU type in executable: '/Users/fissium/.vscode/extensions/charliermarsh.ruff-2023.54.0-darwin-arm64/bundled/libs/bin/ruff'

@charliermarsh
Copy link
Member

Should be fixed in the latest release (2023.56.0, publishing now).

@Fissium
Copy link
Author

Fissium commented Dec 15, 2023

@charliermarsh The original issue has not been resolved. I'm still getting the message byte index 2 is not a char boundary

@Fissium
Copy link
Author

Fissium commented Dec 15, 2023

If I run ruff check ./test.ipynb on a notebook containing

DEFAULT_SYSTEM_PROMPT = (
    "Ты — Сайга, русскоязычный автоматический ассистент. "
    "Ты разговариваешь с людьми и помогаешь им."
)

I get the error.
But using a single-line string instead of a multiline one

DEFAULT_SYSTEM_PROMPT = "Ты — Сайга, русскоязычный автоматический ассистент. Ты разговариваешь с людьми и помогаешь им."

the error doesn't occur.

@konstin
Copy link
Member

konstin commented Dec 15, 2023

Fixed by astral-sh/ruff#9146

dhruvmanila pushed a commit to astral-sh/ruff that referenced this issue Dec 15, 2023
The example below used to panic because we tried to split at 2 bytes in
the 4-bytes character `转`.
```python
def sample_func(xx):
    """
    转置 (transpose)
    """
    return xx.T
```

Fixes #9145
Fixes astral-sh/ruff-vscode#362

The second commit is a small test refactoring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants