ruff/crates
Charlie Marsh ecf61d49fa
Restore existing bindings when unbinding caught exceptions (#5256)
## Summary

In the latest release, we made some improvements to the semantic model,
but our modifications to exception-unbinding are causing some
false-positives. For example:

```py
try:
    v = 3
except ImportError as v:
    print(v)
else:
    print(v)
```

In the latest release, we started unbinding `v` after the `except`
handler. (We used to restore the existing binding, the `v = 3`, but this
was quite complicated.) Because we don't have full branch analysis, we
can't then know that `v` is still bound in the `else` branch.

The solution here modifies `resolve_read` to skip-lookup when hitting
unbound exceptions. So when store the "unbind" for `except ImportError
as v`, we save the binding that it shadowed `v = 3`, and skip to that.

Closes #5249.

Closes #5250.
2023-06-21 12:53:58 -04:00
..
flake8_to_ruff Bump version to 0.0.274 (#5230) 2023-06-20 22:12:32 -04:00
ruff Restore existing bindings when unbinding caught exceptions (#5256) 2023-06-21 12:53:58 -04:00
ruff_benchmark Unify benchmarking and profiling docs (#5145) 2023-06-21 09:39:56 +00:00
ruff_cache Only use a single cache file per Python package (#5117) 2023-06-19 17:46:13 +02:00
ruff_cli Bump version to 0.0.274 (#5230) 2023-06-20 22:12:32 -04:00
ruff_dev Add a script that tests formatter stability on repositories (#5055) 2023-06-19 14:13:38 +00:00
ruff_diagnostics Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_formatter Add BestFittingMode (#5184) 2023-06-20 18:16:01 +02:00
ruff_index Run `rustfmt` on nightly to clean up erroneous comments (#5106) 2023-06-15 00:19:05 +00:00
ruff_macros Refactor top llvm-lines entry (#5147) 2023-06-18 12:39:06 +02:00
ruff_python_ast Fix ArgWithDefault comments handling (#5204) 2023-06-20 20:48:07 +00:00
ruff_python_formatter Format Identifier (#5255) 2023-06-21 17:35:37 +02:00
ruff_python_semantic Restore existing bindings when unbinding caught exceptions (#5256) 2023-06-21 12:53:58 -04:00
ruff_python_stdlib Replace static `CallPath` vectors with `matches!` macros (#5148) 2023-06-16 17:34:42 +00:00
ruff_python_whitespace Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_rustpython Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_testing_macros Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_textwrap Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_wasm Move `copyright` rules to `flake8_copyright` module (#5236) 2023-06-21 01:56:40 +00:00