ruff/crates/ruff_cli/src
Dhruv Manilawala 32fa05765a
Use Jupyter mode while parsing Notebook files (#5552)
## Summary

Enable using the new `Mode::Jupyter` for the tokenizer/parser to parse
Jupyter line magic tokens.

The individual call to the lexer i.e., `lex_starts_at` done by various
rules should consider the context of the source code (is this content
from a Jupyter Notebook?). Thus, a new field `source_type` (of type
`PySourceType`) is added to `Checker` which is being passed around as an
argument to the relevant functions. This is then used to determine the
`Mode` for the lexer.

## Test Plan

Add new test cases to make sure that the magic statement is considered
while generating the diagnostic and autofix:
* For `I001`, if there's a magic statement in between two import blocks,
they should be sorted independently

fixes: #6090
2023-08-05 00:32:07 +00:00
..
bin Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
commands Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
args.rs Extend ruff_dev formatter script to compute statistics and format a project (#5492) 2023-07-07 11:30:12 +00:00
cache.rs Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
diagnostics.rs Use Jupyter mode while parsing Notebook files (#5552) 2023-08-05 00:32:07 +00:00
lib.rs Formatter: Add SourceType to context to enable special formatting for stub files (#6331) 2023-08-04 11:52:26 +00:00
panic.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
printer.rs Use Flags::intersects rather than Flags::contains (#6007) 2023-07-23 02:59:31 +00:00
resolve.rs Log configuration in ruff_dev (#6193) 2023-07-31 17:52:38 +00:00