ruff/crates
Charlie Marsh b49c80f8c8
Use top-level semantic detection for E402 (#6526)
## Summary

Noticed in https://github.com/astral-sh/ruff/pull/6378. Given `import h;
import i`, we don't consider `import i` to be a "top-level" import for
E402 purposes, which is wrong. Similarly, we _do_ consider `import k` to
be a "top-level" import in:

```python
if __name__ == "__main__":
    import j; \
import k
```

Using the semantic detection, rather than relying on newline position,
fixes both cases.

## Test Plan

`cargo test`
2023-08-12 18:52:44 +00:00
..
flake8_to_ruff Bump version to 0.0.284 (#6453) 2023-08-09 13:32:33 -05:00
ruff Use top-level semantic detection for E402 (#6526) 2023-08-12 18:52:44 +00:00
ruff_benchmark Use Jupyter mode while parsing Notebook files (#5552) 2023-08-05 00:32:07 +00:00
ruff_cache Error on zero tab width (#6429) 2023-08-08 16:51:37 -04:00
ruff_cli Bump version to 0.0.284 (#6453) 2023-08-09 13:32:33 -05:00
ruff_dev Use a faster diffing library for the formatter ecosystem checks (#6497) 2023-08-11 15:51:54 +02:00
ruff_diagnostics Skip partial duplicates when applying multi-edit fixes (#6144) 2023-07-29 12:11:57 +00:00
ruff_formatter Fix typo in MeasureMode comment (#6508) 2023-08-11 17:46:59 +00:00
ruff_index Add unreachable code rule (#5384) 2023-07-04 14:27:23 +00:00
ruff_macros Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
ruff_python_ast Add AnyNodeRef.visit_preorder 2023-08-10 08:35:09 +02:00
ruff_python_codegen Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
ruff_python_formatter Add test case for walrus operators in return types (#6438) 2023-08-11 18:28:48 +00:00
ruff_python_index Avoid detecting continuations at non-start-of-line (#6219) 2023-08-01 00:20:29 -04:00
ruff_python_literal Document FormatSpec fields (#6458) 2023-08-09 18:13:29 -04:00
ruff_python_parser Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
ruff_python_resolver Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_semantic Respect scoping rules when identifying builtins (#6468) 2023-08-10 10:20:09 -04:00
ruff_python_stdlib Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_trivia Refactor and rename skip_trailing_trivia (#6312) 2023-08-04 13:30:53 +00:00
ruff_shrinking Use Jupyter mode while parsing Notebook files (#5552) 2023-08-05 00:32:07 +00:00
ruff_source_file Skip BOM when determining Locator's line starts (#6159) 2023-07-29 11:47:13 +00:00
ruff_text_size Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_wasm Set a default on PythonVersion (#6446) 2023-08-09 15:19:27 +00:00