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: 0.10.0
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: 0.11.0
Choose a head ref
  • 7 commits
  • 41 files changed
  • 5 contributors

Commits on Mar 13, 2025

  1. [syntax-errors] Tuple unpacking in for statement iterator clause be…

    …fore Python 3.9 (#16558)
    
    Summary
    --
    
    This PR reuses a slightly modified version of the
    `check_tuple_unpacking` method added for detecting unpacking in `return`
    and `yield` statements to detect the same issue in the iterator clause
    of `for` loops.
    
    I ran into the same issue with a bare `for x in *rest: ...` example
    (invalid even on Python 3.13) and added it as a comment on
    #16520.
    
    I considered just making this an additional `StarTupleKind` variant as
    well, but this change was in a different version of Python, so I kept it
    separate.
    
    Test Plan
    --
    
    New inline tests.
    ntBre authored Mar 13, 2025
    Configuration menu
    Copy the full SHA
    2382fe1 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2025

  1. Fallback to requires-python in certain cases when target-version is n…

    …ot found (#16721)
    
    ## Summary
    
    Restores #16319 after it got
    dropped from the 0.10 release branch :(
    
    ---------
    
    Co-authored-by: dylwil3 <[email protected]>
    MichaReiser and dylwil3 authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    5955650 View commit details
    Browse the repository at this point in the history
  2. [pygrep-hooks]: Detect file-level suppressions comments without rul… (

    #16720)
    
    ## Summary
    
    I accidentially dropped this commit from the Ruff 0.10 release. See
    #16699
    MichaReiser authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    14c5ed5 View commit details
    Browse the repository at this point in the history
  3. [red-knot] Assignments to attributes (#16705)

    ## Summary
    
    This changeset adds proper support for assignments to attributes:
    ```py
    obj.attr = value
    ```
    
    In particular, the following new features are now available:
    
    * We previously didn't raise any errors if you tried to assign to a
    non-existing attribute `attr`. This is now fixed.
    * If `type(obj).attr` is a data descriptor, we now call its `__set__`
    method instead of trying to assign to the load-context type of
    `obj.attr`, which can be different for data descriptors.
    * An initial attempt was made to support unions and intersections, as
    well as possibly-unbound situations. There are some remaining TODOs in
    tests, but they only affect edge cases. Having nested diagnostics would
    be one way that could help solve the remaining cases, I believe.
    
    ## Follow ups
    
    The following things are planned as follow-ups:
    
    - Write a test suite with snapshot diagnostics for various attribute
    assignment errors
    - Improve the diagnostics. An easy improvement would be to highlight the
    right hand side of the assignment as a secondary span (with the rhs type
    as additional information). Some other ideas are mentioned in TODO
    comments in this PR.
    - Improve the union/intersection/possible-unboundness handling
    - Add support for calling custom `__setattr__` methods (see new false
    positive in the ecosystem results)
    
    ## Ecosystem changes
    
    Some changes are related to assignments on attributes with a custom
    `__setattr__` method (see above). Since we didn't notice missing
    attributes at all in store context previously, these are new.
    
    The other changes are related to properties. We previously used their
    read-context type to test the assignment. That results in weird error
    messages, as we often see assignments to `self.property` and then we
    think that those are instance attributes *and* descriptors, leading to
    union types. Now we properly look them up on the meta type, see the
    decorated function, and try to overwrite it with the new value (as we
    don't understand decorators yet). Long story short: the errors are still
    weird, we need to understand decorators to make them go away.
    
    ## Test Plan
    
    New Markdown tests
    sharkdp authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    d03b12e View commit details
    Browse the repository at this point in the history
  4. [red-knot] fix: improve type inference for binary ops on tuples (#16725)

    ## Summary
    
    This PR includes minor improvements to binary operation inference,
    specifically for tuple concatenation.
    
    ### Before
    
    ```py
    reveal_type((1, 2) + (3, 4))  # revealed: @todo(return type of decorated function)
    # If TODO is ignored, the revealed type would be `tuple[1|2|3|4, ...]`
    ```
    
    The `builtins.tuple` type stub defines `__add__`, but it appears to only
    work for homogeneous tuples. However, I think this limitation is not
    ideal for many use cases.
    
    ### After
    
    ```py
    reveal_type((1, 2) + (3, 4))  # revealed: tuple[Literal[1], Literal[2], Literal[3], Literal[4]]
    ```
    
    ## Test Plan
    
    ### Added
    - `mdtest/binary/tuples.md`
    
    ### Affected
    - `mdtest/slots.md` (a test have been moved out of the `False-Negative`
    block.)
    cake-monotone authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    270318c View commit details
    Browse the repository at this point in the history
  5. [red-knot] Preliminary tests for typing.Final (#15917)

    ## Summary
    
    WIP.
    
    Adds some preliminary tests for `typing.Final`.
    
    ## Test Plan
    
    New MD tests
    sharkdp authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    a22d206 View commit details
    Browse the repository at this point in the history
  6. Ruff 0.11.0 (#16723)

    ## Summary
    
    Follow-up release for Ruff v0.10 that now includes the following two
    changes that we intended to ship but slipped:
    
    * Changes to how the Python version is inferred when a `target-version`
    is not specified (#16319)
    * `blanket-noqa` (`PGH004`): Also detect blanked file-level noqa
    comments (and not just line level comments).
    
    ## Test plan
    
    I verified that the binary built on this branch respects the
    `requires-python` setting
    ([logs](https://www.diffchecker.com/qyJWYi6W/), left: v0.10, right:
    v0.11)
    MichaReiser authored Mar 14, 2025
    Configuration menu
    Copy the full SHA
    2cd25ef View commit details
    Browse the repository at this point in the history
Loading