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

Improve rule config resolution #2312

Merged
merged 5 commits into from
Jan 30, 2023

Commits on Jan 30, 2023

  1. refactor: test impl From<&Configuration> for RuleTable

    Previously we tested the resolve_codes helper function directly.
    Since we want to rewrite our resolution logic in the next commit,
    this commit changes the tests to test the more high-level From impl.
    not-my-profile committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    91ab755 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    12d5832 View commit details
    Browse the repository at this point in the history
  3. Improve rule config resolution

    Ruff allows rules to be enabled with `select` and disabled with
    `ignore`, where the more specific rule selector takes precedence,
    for example:
    
        `--select ALL --ignore E501` selects all rules except E501
        `--ignore ALL --select E501` selects only E501
    
    (If both selectors have the same specificity ignore selectors
    take precedence.)
    
    Ruff always had two quirks:
    
    * If `pyproject.toml` specified `ignore = ["E501"]` then you could
      previously not override that with `--select E501` on the command-line
      (since the resolution didn't take into account that the select was
      specified after the ignore).
    
    * If `pyproject.toml` specified `select = ["E501"]` then you could
      previously not override that with `--ignore E` on the command-line
      (since the resolution didn't take into account that the ignore was
      specified after the select).
    
    Since d067efe (astral-sh#1245)
    `extend-select` and `extend-ignore` always override
    `select` and `ignore` and are applied iteratively in pairs,
    which introduced another quirk:
    
    * If some `pyproject.toml` file specified `extend-select`
      or `extend-ignore`, `select` and `ignore` became pretty much
      unreliable after that with no way of resetting that.
    
    This commit fixes all of these quirks by making later configuration
    sources take precedence over earlier configuration sources.
    
    While this is a breaking change, we expect most ruff configuration
    files to not rely on the previous unintutive behavior.
    not-my-profile committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    7f92c42 View commit details
    Browse the repository at this point in the history
  4. Exclude deprecated extend-ignore from the JSON schema

    Now that the option is deprecated we no longer
    want IDEs to suggest it in their autocompletion.
    not-my-profile committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    7e47d62 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0264772 View commit details
    Browse the repository at this point in the history