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.5.3
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.5.4
Choose a head ref
  • 17 commits
  • 45 files changed
  • 11 contributors

Commits on Jul 18, 2024

  1. [red-knot] support implicit global name lookups (#12374)

    Support falling back to a global name lookup if a name isn't defined in
    the local scope, in the cases where that is correct according to Python
    semantics.
    
    In class scopes, a name lookup checks the local namespace first, and if
    the name isn't found there, looks it up in globals.
    
    In function scopes (and type parameter scopes, which are function-like),
    if a name has any definitions in the local scope, it is a local, and
    accessing it when none of those definitions have executed yet just
    results in an `UnboundLocalError`, it does not fall back to a global. If
    the name does not have any definitions in the local scope, then it is an
    implicit global.
    
    Public symbol type lookups never include such a fall back. For example,
    if a name is not defined in a class scope, it is not available as a
    member on that class, even if a name lookup within the class scope would
    have fallen back to a global lookup.
    
    This PR makes the `@override` lint rule work again.
    
    Not yet included/supported in this PR:
    
    * Support for free variables / closures: a free symbol in a nested
    function-like scope referring to a symbol in an outer function-like
    scope.
    * Support for `global` and `nonlocal` statements, which force a symbol
    to be treated as global or nonlocal even if it has definitions in the
    local scope.
    * Module-global lookups should fall back to builtins if the name isn't
    found in the module scope.
    
    I would like to expose nicer APIs for the various kinds of symbols
    (explicit global, implicit global, free, etc), but this will also wait
    for a later PR, when more kinds of symbols are supported.
    carljm authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    519eca9 View commit details
    Browse the repository at this point in the history
  2. [red-knot] rename module_global to global (#12385)

    Per comments in #12269, "module
    global" is kind of long, and arguably redundant.
    
    I tried just using "module" but there were too many cases where I felt
    this was ambiguous. I like the way "global" works out better, though it
    does require an understanding that in Python "global" generally means
    "module global" not "globally global" (though in a sense module globals
    are also globally global since modules are singletons).
    carljm authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    181e7b3 View commit details
    Browse the repository at this point in the history
  3. [red-knot] use a simpler builtin in the benchmark (#12393)

    In preparation for supporting resolving builtins, simplify the benchmark
    so it doesn't look up `str`, which is actually a complex builtin to deal
    with because it inherits `Sequence[str]`.
    
    Co-authored-by: Alex Waygood <[email protected]>
    carljm and AlexWaygood authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    fa5b19d View commit details
    Browse the repository at this point in the history
  4. [pydocstyle] Escaped docstring in docstring (D301 ) (#12192)

    <!--
    Thank you for contributing to Ruff! To help us out with reviewing,
    please consider the following:
    
    - Does this pull request include a summary of the change? (See below.)
    - Does this pull request include a descriptive title?
    - Does this pull request include references to any relevant issues?
    -->
    
    ## Summary
    
    <!-- What's the purpose of the change? What does it do, and why? -->
    This PR updates D301 rule to allow inclduing escaped docstring, e.g.
    `\"""Foo.\"""` or `\"\"\"Bar.\"\"\"`, within a docstring.
    
    Related issue: #12152 
    
    ## Test Plan
    
    Add more test cases to D301.py and update the snapshot file.
    
    <!-- How was it tested? -->
    ukyen8 authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    0ba7fc6 View commit details
    Browse the repository at this point in the history
  5. [ruff] Rename RUF007 to zip-instead-of-pairwise (#12399)

    ## Summary
    
    <!-- What's the purpose of the change? What does it do, and why? -->
    
    Renames the rule
    [RUF007](https://docs.astral.sh/ruff/rules/pairwise-over-zipped/) from
    `pairwise-over-zipped` to `zip-instead-of-pairwise`. This closes #12397.
    
    Specifically, in this PR:
    
    - The file containing the rule was renamed
    - The struct was renamed
    - The function implementing the rule was renamed
    
    ## Testing
    
    <!-- How was it tested? -->
    
    - `cargo test`
    - Docs re-built locally and verified that new rule name is displayed.
    (Screenshots below).
    
    <img width="939" alt="New rule name in rule summary"
    src="https://github.com/user-attachments/assets/bf638bc9-1b7a-4675-99bf-e4de88fec167">
    
    <img width="805" alt="New rule name in rule details"
    src="https://github.com/user-attachments/assets/6fffd745-2568-424a-84e5-f94a41351022">
    dylwil3 authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    d617470 View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2024

  1. Configuration menu
    Copy the full SHA
    a62e2d2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ad19b3f View commit details
    Browse the repository at this point in the history
  3. [red-knot] Fix bug where module resolution would not be invalidated i…

    …f an entire package was deleted (#12378)
    AlexWaygood authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    5f96f69 View commit details
    Browse the repository at this point in the history
  4. [red-knot] trace file when inferring types (#12401)

    When poring over traces, the ones that just include a definition or
    symbol or expression ID aren't very useful, because you don't know which
    file it comes from. This adds that information to the trace.
    
    I guess the downside here is that if calling `.file(db)` on a
    scope/definition/expression would execute other traced code, it would be
    marked as outside the span? I don't think that's a concern, because I
    don't think a simple field access on a tracked struct should ever
    execute our code. If I'm wrong and this is a problem, it seems like the
    tracing crate has this feature where you can record a field as
    `tracing::field::Empty` and then fill in its value later with
    `span.record(...)`, but when I tried this it wasn't working for me, not
    sure why.
    
    I think there's a lot more we can do to make our tracing output more
    useful for debugging (e.g. record an event whenever a
    definition/symbol/expression/use id is created with the details of that
    definition/symbol/expression/use), this is just dipping my toes in the
    water.
    carljm authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    f82bb67 View commit details
    Browse the repository at this point in the history
  5. [red-knot] fix incremental benchmark (#12400)

    We should write `BAR_CODE` to `bar.py`, not to `foo.py`.
    carljm authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    1c7b840 View commit details
    Browse the repository at this point in the history
  6. [red-knot] Resolve symbols from builtins.pyi in the stdlib if they …

    …cannot be found in other scopes (#12390)
    
    Co-authored-by: Carl Meyer <[email protected]>
    AlexWaygood and carljm authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    d8cf8ac View commit details
    Browse the repository at this point in the history
  7. Update docs Settings output-format default (#12409)

    ## Update docs Settings output-format default
    
    Fixes #12350
    
    ## Test Plan
    
    Run all automation mentioned here
    https://github.com/astral-sh/ruff/blob/fe04f2b09d0b676f1fa09f732e907ef64deffbb1/CONTRIBUTING.md#development
    
    Manually verified changes in the generated MkDocs site.
    
    Co-authored-by: Oleksandr Zavertniev <[email protected]>
    sashko1988 and Oleksandr Zavertniev authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    ca22248 View commit details
    Browse the repository at this point in the history
  8. Fix the Github link error for Neovim in the setup for editors in the …

    …docs. (#12410)
    
    ## Summary
    
    Fix Github link error for Neovim setup editors .
    
    ## Test Plan
    Click Neovim Github link with mkdocs on local.
    FishAlchemist authored Jul 19, 2024
    Configuration menu
    Copy the full SHA
    c0a2b49 View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2024

  1. Configuration menu
    Copy the full SHA
    4bcc96a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2c1926b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3664f85 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    53b84ab View commit details
    Browse the repository at this point in the history
Loading