-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Comparing changes
Open a pull request
base repository: astral-sh/ruff
base: 0.8.5
head repository: astral-sh/ruff
compare: 0.8.6
- 19 commits
- 94 files changed
- 14 contributors
Commits on Jan 2, 2025
-
Remove
Type::tuple
in favor ofTupleType::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.
Configuration menu - View commit details
-
Copy full SHA for 7671a3b - Browse repository at this point
Copy the full SHA 7671a3bView commit details -
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>
Configuration menu - View commit details
-
Copy full SHA for 2327082 - Browse repository at this point
Copy the full SHA 2327082View commit details -
Avoid syntax error when removing int over multiple lines (#15230)
## Summary Closes #15226.
Configuration menu - View commit details
-
Copy full SHA for 3c3f35a - Browse repository at this point
Copy the full SHA 3c3f35aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2355472 - Browse repository at this point
Copy the full SHA 2355472View commit details
Commits on Jan 3, 2025
-
refactor(AIR303): move duplicate qualified_name.to_string() to Diagno…
Configuration menu - View commit details
-
Copy full SHA for d464ef6 - Browse repository at this point
Copy the full SHA d464ef6View commit details -
[
pylint
] Re-implementunreachable
(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>
Configuration menu - View commit details
-
Copy full SHA for a3d873e - Browse repository at this point
Copy the full SHA a3d873eView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 835b453 - Browse repository at this point
Copy the full SHA 835b453View commit details -
[
pyflakes
] Ignore errors in@no_type_check
string annotations (`F……722`, `F821`) (#15215)
Configuration menu - View commit details
-
Copy full SHA for 6180f78 - Browse repository at this point
Copy the full SHA 6180f78View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1218bc6 - Browse repository at this point
Copy the full SHA 1218bc6View commit details -
TD003: remove issue code length restriction (#15175)
Co-authored-by: Micha Reiser <micha@reiser.io>
Configuration menu - View commit details
-
Copy full SHA for 0dbfa8d - Browse repository at this point
Copy the full SHA 0dbfa8dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0837cdd - Browse repository at this point
Copy the full SHA 0837cddView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 706d87f - Browse repository at this point
Copy the full SHA 706d87fView commit details -
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.)
Configuration menu - View commit details
-
Copy full SHA for 75015b0 - Browse repository at this point
Copy the full SHA 75015b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 842f882 - Browse repository at this point
Copy the full SHA 842f882View commit details -
[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
Configuration menu - View commit details
-
Copy full SHA for bde8ecd - Browse repository at this point
Copy the full SHA bde8ecdView commit details -
Configuration menu - View commit details
-
Copy full SHA for baf0d66 - Browse repository at this point
Copy the full SHA baf0d66View commit details
Commits on Jan 4, 2025
-
Configuration menu - View commit details
-
Copy full SHA for e4d9fe0 - Browse repository at this point
Copy the full SHA e4d9fe0View commit details -
Configuration menu - View commit details
-
Copy full SHA for f319531 - Browse repository at this point
Copy the full SHA f319531View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b907c1 - Browse repository at this point
Copy the full SHA 6b907c1View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff 0.8.5...0.8.6