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

[Linter panic] ruff 0.0.258: 'internal error: entered unreachable code: Expected docstring to start with a valid triple- or single-quote prefix', crates/ruff_python_ast/src/str.rs:38:5 #3678

Closed
XuehaiPan opened this issue Mar 23, 2023 · 2 comments · Fixed by #3698
Assignees
Labels
bug Something isn't working

Comments

@XuehaiPan
Copy link
Contributor

XuehaiPan commented Mar 23, 2023

Ref https://github.com/metaopt/optree/actions/runs/4497862525/jobs/7913866886, the step pre-commit (ruff 0.0.257 runs successfully), while ruff 0.0.258 reports panic.

Create a new isolated virtual environment:

$ git clone --depth=1 https://github.com/metaopt/optree.git
$ cd optree
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install --upgrade ruff
Collecting ruff
  Using cached ruff-0.0.258-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB)
Installing collected packages: ruff
Successfully installed ruff-0.0.258

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
$ ruff --version             
ruff 0.0.258

The panic is not always reproducible:

$ source venv/bin/activate
$ ruff check optree/typing.py  # OK
$ ruff check optree/typing.py  # OK

$ deactivate
$ source venv/bin/activate
$ ruff check optree/typing.py
warning: Linting panicked optree/typing.py: This indicates a bug in `ruff`. If you could open an issue at:

https://github.com/charliermarsh/ruff/issues/new?title=%5BLinter%20panic%5D

with the relevant file contents, the `pyproject.toml` settings, and the following stack trace, we'd be very appreciative!

panicked at 'internal error: entered unreachable code: Expected docstring to start with a valid triple- or single-quote prefix', crates/ruff_python_ast/src/str.rs:38:5
Backtrace:    0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: __libc_start_main
             at /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
  19: <unknown>

pyproject.toml: https://github.com/metaopt/optree/blob/828749a91b985cb56fc0888c26939080be4f677d/pyproject.toml#L139-L227
optree/typing.py: https://github.com/metaopt/optree/blob/828749a91b985cb56fc0888c26939080be4f677d/optree/typing.py

All docstrings are valid and start with triple-quotes. No panic was reported for the previous release ruff 0.0.257.

I have

[tool.ruff]
typing-modules = ["optree.typing"]

in my configuration. Not sure if this is the cause here.

@MichaReiser MichaReiser added the bug Something isn't working label Mar 23, 2023
@charliermarsh
Copy link
Member

Thanks! I'll take a look today.

@charliermarsh charliermarsh self-assigned this Mar 23, 2023
@charliermarsh
Copy link
Member

Reproduced...

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.

3 participants