Skip to content

Misleading error hint about unknown configuration file keys #12359

Open
@pradyunsg

Description

Version: 0.5.2

Reproduction instructions

  1. Create a ruff.toml file with the contents:

    extend-select = [
        "W", # pycodestyle warnings
        "I", # isort
        "N", # pep8-naming
        "D", # pydocstyle
        "B", # flake8-bugbear
        "PYI" # flake8-pyi
    ]
    
    # Group errors by file.
    output-format = "grouped"
    
    # Show source context of error.
    show-source = true
    
    # Show summary of fixes.
    show-fixes = true
  2. Create a src/foo.py file with no contents.

  3. Run ruff check and see the problematic error message.

Output

ruff check
ruff failed
  Cause: Failed to parse /Users/[...]/ruff.toml
  Cause: TOML parse error at line 1, column 1
  |
1 | extend-select = [
  | ^^^^^^^^^^^^^^^^^
unknown field `show-source`

The error message points to the line about extend-select when complaining about show-source as the key that is unknown. It would be better for the error to point at line 14 entirely OR, ideally, point only at show-source part of that line since that's the key in the key-value pair in the configuration file that is unknown.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfigurationRelated to settings and configuration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions