mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00
Update E402
to work at cell level for notebooks (#8872)
## Summary This PR updates the `E402` rule to work at cell level for Jupyter notebooks. This is enabled only in preview to gather feedback. The implementation basically resets the import boundary flag on the semantic model when we encounter the first statement in a cell. Another potential solution is to introduce `E403` rule that is specifically for notebooks that works at cell level while `E402` will be disabled for notebooks. ## Test Plan Add a notebook with imports in multiple cells and verify that the rule works as expected. resolves: #8669
This commit is contained in:
parent
4957d94beb
commit
b28556d739
7 changed files with 204 additions and 9 deletions
|
@ -68,7 +68,7 @@ pub enum TomlSourceType {
|
|||
Unrecognized,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, is_macro::Is)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, is_macro::Is)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum PySourceType {
|
||||
/// The source is a Python file (`.py`).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue