Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: astral-sh/ruff
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.276
Choose a base ref
...
head repository: astral-sh/ruff
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.277
Choose a head ref
  • 15 commits
  • 112 files changed
  • 7 contributors

Commits on Jul 3, 2023

  1. Don't add a magic trailing comma for a single entry (#5463)

    ## Summary
    
    If a comma separated list has only one entry, black will respect the
    magic trailing comma, but it will not add a new one.
    
    The following code will remain as is:
    
    ```python
    b1 = [
        aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
    ]
    b2 = [
        aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa,
    ]
    b3 = [
        aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa,
        aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
    ]
    ```
    
    ## Test Plan
    
    This was first discovered in
    https://github.com/django/django/blob/7eeadc82c2f7d7a778e3bb43c34d642e6275dacf/django/contrib/admin/checks.py#L674-L681,
    which i've minimized into a call test.
    
    I've added tests for the three cases (one entry + no comma, one entry +
    comma, more than one entry) to the list tests.
    
    The diffs from the black tests get smaller.
    konstin authored Jul 3, 2023
    Configuration menu
    Copy the full SHA
    a647f31 View commit details
    Browse the repository at this point in the history
  2. Turn Linters', etc. implicit into_iter()s into explicit rules() (#…

    …5436)
    
    ## Summary
    
    As discussed on ~IRC~ Discord, this will make it easier for e.g. the
    docs generation stuff to get all rules for a linter (using
    `all_rules()`) instead of just non-nursery ones, and it also makes it
    more Explicit Is Better Than Implicit to iterate over linter rules.
    
    Grepping for `Item = Rule` reveals some remaining implicit
    `IntoIterator`s that I didn't feel were necessarily in scope for this
    (and honestly, iterating over a `RuleSet` makes sense).
    akx authored Jul 3, 2023
    Configuration menu
    Copy the full SHA
    6acc316 View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2023

  1. Format import statements (#5493)

    ## Summary
    
    Format import statements in all their variants. Specifically, this
    implemented formatting `StmtImport`, `StmtImportFrom` and `Alias`.
    
    ## Test Plan
    
    I added some custom snapshots, even though this has been covered well by
    black's tests.
    konstin authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    787e2fd View commit details
    Browse the repository at this point in the history
  2. check-formatter-stability: Remove newlines and add --error-file (#5491

    )
    
    ## Summary
    
    This makes the output of `check-formatter-stability` more concise by
    removing extraneous newlines. It also adds a `--error-file` option to
    that script that allows creating a file with just the errors (without
    the status messages) to share with others.
    
    ## Test Plan
    
    I ran it over CPython and looked at the output. I then added the
    `--error-file` option and looked at the contents of the file
    konstin authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    937de12 View commit details
    Browse the repository at this point in the history
  3. Add unreachable code rule (#5384)

    Co-authored-by: Thomas de Zeeuw <[email protected]>
    Co-authored-by: Micha Reiser <[email protected]>
    3 people authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    0b963dd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    521e6de View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    75da72b View commit details
    Browse the repository at this point in the history
  6. Avoid PERF rules for iteration-dependent assignments (#5508)

    ## Summary
    
    We need to avoid raising "rewrite as a comprehension" violations in
    cases like:
    
    ```python
    d = defaultdict(list)
    
    for i in [1, 2, 3]:
        d[i].append(i**2)
    ```
    
    Closes #5494.
    
    Closes #5500.
    charliermarsh authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    c395e44 View commit details
    Browse the repository at this point in the history
  7. [pylint] Implement Pylint typevar-name-mismatch (C0132) (#5501)

    ## Summary
    
    Implement Pylint `typevar-name-mismatch` (`C0132`) as
    `type-param-name-mismatch` (`PLC0132`). Includes documentation. Related
    to #970.
    
    The Pylint implementation checks only `TypeVar`, but this PR checks
    `TypeVarTuple`, `ParamSpec`, and `NewType` as well. This seems to better
    represent the Pylint rule's [intended
    behaviour](pylint-dev/pylint#5224).
    
    Full disclosure: I am not a fan of the translated name and think it
    should probably be different.
    
    ## Test Plan
    
    `cargo test`
    tjkuson authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    0e67757 View commit details
    Browse the repository at this point in the history
  8. Merge clippy and clippy (wasm) jobs on CI (#5447)

    ## Summary
    
    The clippy wasm job rarely fails if regular clippy doesn't, wasm clippy
    still compiles a lot of native dependencies for the proc macro and we
    have less CI jobs overall, so i think this an improvement to our CI.
    
    ```shell
    $ CARGO_TARGET_DIR=target-wasm cargo clippy -p ruff_wasm --target wasm32-unknown-unknown --all-features -j 2 -- -D warnings
    $ du -sh target-wasm/*
    12K	target-wasm/CACHEDIR.TAG
    582M	target-wasm/debug
    268M	target-wasm/wasm32-unknown-unknown
    ```
    
    ## Test plan
    
    n/a
    konstin authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    0a26201 View commit details
    Browse the repository at this point in the history
  9. Avoid returning first-match for rule prefixes (#5511)

    Closes #5495, but there's a TODO here to improve this further. The
    current `from_code` implementation feels really indirect.
    charliermarsh authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    952c623 View commit details
    Browse the repository at this point in the history
  10. Add ruff rule --all subcommand (with JSON output) (#5059)

    ## Summary
    
    This adds a `ruff rule --all` switch that prints out a human-readable
    Markdown or a machine-readable JSON document of the lint rules known to
    Ruff.
    
    I needed a machine-readable document of the rules [for a
    project](#5078), and
    figured it could be useful for other people – or tooling! – to be able
    to interrogate Ruff about its arcane knowledge.
    
    The JSON output is an array of the same objects printed by `ruff rule
    --format=json`.
    
    ## Test Plan
    
    I ran `ruff rule --all --format=json`. I think more might be needed, but
    maybe a snapshot test is overkill?
    akx authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    d7214e7 View commit details
    Browse the repository at this point in the history
  11. Tweak prefix match to use .all_rules() (#5512)

    ## Summary
    
    No behavior change, but I think this is a little cleaner.
    charliermarsh authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    485d997 View commit details
    Browse the repository at this point in the history
  12. Add .ipynb_checkpoints, .pyenv, .pytest_cache, and .vscode to default…

    … excludes (#5513)
    
    ## Summary
    
    VS Code extensions are
    [recommended](https://code.visualstudio.com/docs/python/settings-reference#_linting-settings)
    to exclude `.vscode` and `site-packages`. Black also now omits
    `.vscode`, `.pytest_cache`, and `.ipynb_checkpoints` by default.
    Omitting `.pyenv` is similar to omitting virtual environments, but
    really only matters in the context of VS Code (see:
    #5509).
    
    Closes: #5510.
    charliermarsh authored Jul 4, 2023
    Configuration menu
    Copy the full SHA
    da1c320 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    324455f View commit details
    Browse the repository at this point in the history
Loading