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.8.5
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.8.6
Choose a head ref
  • 19 commits
  • 94 files changed
  • 14 contributors

Commits on Jan 2, 2025

  1. Remove Type::tuple in favor of TupleType::from_elements (#15218)

    ## Summary
    
    Remove `Type::tuple` in favor of `TupleType::from_elements`, avoid a few
    intermediate `Vec`tors. Resolves an old [review
    comment](#14744 (comment)).
    
    ## Test Plan
    
    New regression test for something I ran into while implementing this.
    sharkdp authored Jan 2, 2025
    Configuration menu
    Copy the full SHA
    7671a3b View commit details
    Browse the repository at this point in the history
  2. Migrate renovate config (#15228)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
    renovate[bot] and AlexWaygood authored Jan 2, 2025
    Configuration menu
    Copy the full SHA
    2327082 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3c3f35a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2355472 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2025

  1. refactor(AIR303): move duplicate qualified_name.to_string() to Diagno…

    …stic argument (#15220)
    
    ## Summary
    
    Refactor airflow rule logic like
    86bdc2e
    
    ## Test Plan
    
    No functionality change. Existing test cases work as it was
    Lee-W authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    d464ef6 View commit details
    Browse the repository at this point in the history
  2. [pylint] Re-implement unreachable (PLW0101) (#10891)

    ## Summary
    
    This PR re-introduces the control-flow graph implementation which was
    first introduced in #5384, and then removed in #9463 due to not being
    feature complete. Mainly, it lacked the ability to process
    `try`-`except` blocks, along with some more minor bugs.
    
    Closes #8958 and #8959 and #14881.
    
    ## Overview of Changes
    
    I will now highlight the major changes implemented in this PR, in order
    of implementation.
    
    1. Introduced a post-processing step in loop handling to find any
    `continue` or `break` statements within the loop body and redirect them
    appropriately.
    2. Introduced a loop-continue block which is always placed at the end of
    loop blocks, and ensures proper looping regardless of the internal logic
    of the block. This resolves #8958.
    3. Implemented `try` processing with the following logic (resolves
    #8959):
    1. In the example below the cfg first encounters a conditional
    `ExceptionRaised` forking if an exception was (or will be) raised in the
    try block. This is not possible to know (except for trivial cases) so we
    assume both paths can be taken unconditionally.
    2. Going down the `try` path the cfg goes `try`->`else`->`finally`
    unconditionally.
    3. Going down the `except` path the cfg will meet several conditional
    `ExceptionCaught` which fork depending on the nature of the exception
    caught. Again there's no way to know which exceptions may be raised so
    both paths are assumed to be taken unconditionally.
    4. If none of the exception blocks catch the exception then the cfg
    terminates by raising a new exception.
    5. A post-processing step is also implemented to redirect any `raises`
    or `returns` within the blocks appropriately.
    ```python
    def func():
        try:
            print("try")
        except Exception:
            print("Exception")
        except OtherException as e:
            print("OtherException")
        else:
            print("else")
        finally:
            print("finally")
    ```
    ```mermaid
    flowchart TD
      start(("Start"))
      return(("End"))
      block0[["`*(empty)*`"]]
      block1["print(#quot;finally#quot;)\n"]
      block2["print(#quot;else#quot;)\n"]
      block3["print(#quot;try#quot;)\n"]
      block4[["Exception raised"]]
      block5["print(#quot;OtherException#quot;)\n"]
      block6["try:
            print(#quot;try#quot;)
        except Exception:
            print(#quot;Exception#quot;)
        except OtherException as e:
            print(#quot;OtherException#quot;)
        else:
            print(#quot;else#quot;)
        finally:
            print(#quot;finally#quot;)\n"]
      block7["print(#quot;Exception#quot;)\n"]
      block8["try:
            print(#quot;try#quot;)
        except Exception:
            print(#quot;Exception#quot;)
        except OtherException as e:
            print(#quot;OtherException#quot;)
        else:
            print(#quot;else#quot;)
        finally:
            print(#quot;finally#quot;)\n"]
      block9["try:
            print(#quot;try#quot;)
        except Exception:
            print(#quot;Exception#quot;)
        except OtherException as e:
            print(#quot;OtherException#quot;)
        else:
            print(#quot;else#quot;)
        finally:
            print(#quot;finally#quot;)\n"]
    
      start --> block9
      block9 -- "Exception raised" --> block8
      block9 -- "else" --> block3
      block8 -- "Exception" --> block7
      block8 -- "else" --> block6
      block7 --> block1
      block6 -- "OtherException" --> block5
      block6 -- "else" --> block4
      block5 --> block1
      block4 --> return
      block3 --> block2
      block2 --> block1
      block1 --> block0
      block0 --> return
    ``` 
    6. Implemented `with` processing with the following logic:
    1. `with` statements have no conditional execution (apart from the
    hidden logic handling the enter and exit), so the block is assumed to
    execute unconditionally.
    2. The one exception is that exceptions raised within the block may
    result in control flow resuming at the end of the block. Since it is not
    possible know if an exception will be raised, or if it will be handled
    by the context manager, we assume that execution always continues after
    `with` blocks even if the blocks contain `raise` or `return` statements.
    This is handled in a post-processing step.
    
    ## Test Plan
    
    Additional test fixtures and control-flow fixtures were added.
    
    ---------
    
    Co-authored-by: Micha Reiser <micha@reiser.io>
    Co-authored-by: dylwil3 <dylwil3@gmail.com>
    3 people authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    a3d873e View commit details
    Browse the repository at this point in the history
  3. style(AIR302): rename removed_airflow_plugin_extension as check_airfl…

    …ow_plugin_extension (#15233)
    
    ## Summary
    
    during the previous refactor, this renaming was missed
    
    ## Test Plan
    
    no functionality changed
    Lee-W authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    835b453 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6180f78 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1218bc6 View commit details
    Browse the repository at this point in the history
  6. TD003: remove issue code length restriction (#15175)

    Co-authored-by: Micha Reiser <micha@reiser.io>
    mdbernard and MichaReiser authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    0dbfa8d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0837cdd View commit details
    Browse the repository at this point in the history
  8. Show errors for attempted fixes only when passed --verbose (#15237)

    The default logging level for diagnostics includes logs written using
    the `log` crate with level `error`, `warn`, and `info`. An unsuccessful
    fix attached to a diagnostic via `try_set_fix` or `try_set_optional_fix`
    was logged at level `error`. Note that the user would see these messages
    even without passing `--fix`, and possibly also on lines with `noqa`
    comments.
    
    This PR changes the logging level here to a `debug`. We also found
    ad-hoc instances of error logging in the implementations of several
    rules, and have replaced those with either a `debug` or call to
    `try_set{_optional}_fix`.
    
    Closes #15229
    dylwil3 authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    706d87f View commit details
    Browse the repository at this point in the history
  9. Attribute panics to the mdtests that cause them (#15241)

    This updates the mdtest harness to catch any panics that occur during
    type checking, and to display the panic message as an mdtest failure.
    (We don't know which specific line causes the failure, so we attribute
    panics to the first line of the test case.)
    dcreager authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    75015b0 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    842f882 View commit details
    Browse the repository at this point in the history
  11. [red-knot] Remove unneeded branch in Type::is_equivalent_to() (#15242)

    ## Summary
    
    We understand `sys.version_info` branches now! As such, I _believe_ this
    branch is no longer required; all tests pass without it. I also ran
    `QUICKCHECK_TESTS=100000 cargo test -p red_knot_python_semantic --
    --ignored types::property_tests::stable`, and no tests failed except for
    the known issue with `Type::is_assignable_to()`
    (#14899)
    
    ## Test Plan
    
    See above
    AlexWaygood authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    bde8ecd View commit details
    Browse the repository at this point in the history
  12. Update salsa (#15243)

    MichaReiser authored Jan 3, 2025
    Configuration menu
    Copy the full SHA
    baf0d66 View commit details
    Browse the repository at this point in the history

Commits on Jan 4, 2025

  1. Configuration menu
    Copy the full SHA
    e4d9fe0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f319531 View commit details
    Browse the repository at this point in the history
  3. Ruff 0.8.6 (#15253)

    MichaReiser authored Jan 4, 2025
    Configuration menu
    Copy the full SHA
    6b907c1 View commit details
    Browse the repository at this point in the history
Loading