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

[Panic] Ruff VSCode extension crashes every time the word def is written in a class #11037

Closed
lmanc opened this issue Apr 19, 2024 · 5 comments
Closed
Labels
bug Something isn't working parser Related to the parser

Comments

@lmanc
Copy link
Contributor

lmanc commented Apr 19, 2024

Hi, today while using the Ruff VSCode extension, Ruff crashed with the following message:

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 D:\a\ruff\ruff\crates\ruff_text_size\src\range.rs:48:9: assertion failed: start.raw <= end.raw note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace )

I'm keeping the title as the message suggests. For the other parts:

  • "quoting the executed command", since I'm using the VSCode extension, I'm not executing it via CLI. I'm uncertain about the "implicit" commands that are run under the hood.
  • "relevant file contents", Ruff crashes every time I start writing a new function with the keyword def in this Django REST Framework view. I can't share the entire file, but here's an excerpt:
    # Imports and more classes above
    
    class WiseSettingsGroupsView(APIView):
        def get(self, request):
            # snip
            return Response(data)
            
        def serialize_data(self):
            # the function that make Ruff crash as soon as I type `def` here
            
    # Other classes
  • "[...] and pyproject.toml settings", here they are:
    # Include Jupyter notebooks
    include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
    
    # Exclude a variety of commonly ignored directories.
    exclude = [
        ".bzr",
        ".direnv",
        ".eggs",
        ".git",
        ".git-rewrite",
        ".hg",
        ".mypy_cache",
        ".nox",
        ".pants.d",
        ".pytype",
        ".ruff_cache",
        ".svn",
        ".tox",
        ".venv",
        "__pypackages__",
        "_build",
        "buck-out",
        "build",
        "dist",
        "node_modules",
        "venv",
    ]
    
    line-length = 99 # Used by both linter and E501
    indent-width = 4
    
    [lint.pycodestyle]
    max-doc-length = 80
    
    [lint]
    select = [
        "A",     # flake8-builtins
    #   "ANN",   # flake8-annotations
        "ARG",   # flake8-unused-arguments
        "B",     # flake8-bugbear
        "BLE",   # flake8-blind-except
        "COM",   # flake8-commas
        "C4",    # flake8-comprehensions
        "C90",   # mccabe
        "D",     # pydocstyle
        'DJ',    # flake8-django
        "E",     # pycodestyle errors
        "ERA",   # eradicate
        "EM",    # flake8-errmsg
        "F",     # pyflakes
        "FBT",   # flake8-boolean-trap
        "FLY",   # flynt
        "FURB",  # refurb
        "G",     # flake8-logging-format
        "I",     # isort
        "ICN",   # flake8-import-conventions
        "INP",   # flake8-no-pep420
        "ISC",   # flake8-implicit-str-concat
        "N",     # pep8-naming
        "PD",    # pandas-vet
        "PERF",  # Perflint
        "PIE",   # flake8-pie
        "PL",    # Pylint
        "PTH",   # flake8-use-pathlib
        "PT",    # flake8-pytest-style
        "RET",   # flake8-return
        "RSE",   # flake8-raise
        "RUF",   # Ruff-specific rules
        "S",     # flake8-bandit
        "SIM",   # flake8-simplify
        "SLF",   # flake8-self
        "TID",   # flake8-tidy-imports
        "TRY",   # tryceratops
        "T10",   # flake8-debugger
        "UP",    # pyupgrade
        "W",     # pycodestyle warnings
    ]
    
    ignore = [
        "ANN101",  # missing-type-self
        "ANN102",  # missing-type-cls
        "ANN204",  # missing-return-type-special-method
        "COM812",  # missing-trailing-comma
        "D100",    # missing docstring in public module
        "D104",    # missing docstring in public package
        "D106",    # missing docstring in public nested class
        "PLR0913", # too-many-arguments
        "W191",    # indentation contains tabs
    ]
    
    # Allow fix for all enabled rules (when `--fix`) is provided.
    fixable = ["ALL"]
    unfixable = []
    
    [extend-per-file-ignores]
    "{tests/*,test*.py}" = [
        "ANN",    # flake8-annotations
        "INP001", # implicit-namespace-package
        "N802",   # invalid-function-name
        "PD901",  # pandas-df-variable-name
        "S",      # flake8-bandit
        "S301",   # suspicious-pickle-usage
        "SLF001", # private-member-access
    ]
    
    "{admin.py,models.py,serializers.py,views.py}" = [
        "RUF012",    # mutable-class-default
    ]
    
    [format]
    # Use single quotes for strings.
    quote-style = "single"
    
    # Like Black, indent with spaces, rather than tabs.
    indent-style = "space"
    
    # Like Black, respect magic trailing commas.
    skip-magic-trailing-comma = false
    
    # Like Black, automatically detect the appropriate line ending.
    line-ending = "auto"
    
    [pydocstyle]
    convention = "numpy"
@lmanc lmanc changed the title [Panic] [Panic] Ruff crashes when adding a function to a Django REST Framework view Apr 19, 2024
@MichaReiser
Copy link
Member

Thanks for opening the issue and the in detail description.

@dhruvmanila Is my assumption correct that this was probably fixed by #11032 ?

@lmanc
Copy link
Contributor Author

lmanc commented Apr 19, 2024

I've noticed that it happens every time I use the keyword def in any class.

@lmanc lmanc changed the title [Panic] Ruff crashes when adding a function to a Django REST Framework view [Panic] Ruff VSCode extensin crashes every time the word def is written in a class Apr 19, 2024
@lmanc lmanc changed the title [Panic] Ruff VSCode extensin crashes every time the word def is written in a class [Panic] Ruff VSCode extension crashes every time the word def is written in a class Apr 19, 2024
@lmanc
Copy link
Contributor Author

lmanc commented Apr 19, 2024

And it crashes as soon as I type the space after def.

@dhruvmanila
Copy link
Member

Yes, it's fixed on the latest extension version. Can you try it out? I can confirm it's not happening now.

@charliermarsh charliermarsh added bug Something isn't working parser Related to the parser labels Apr 19, 2024
@lmanc
Copy link
Contributor Author

lmanc commented Apr 19, 2024

I updated the extension to v2024.20.0 and restarted all the extensions on VSCode. Now it's not happening to me either.

Impressively fast, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Related to the parser
Projects
None yet
Development

No branches or pull requests

4 participants