mirror of https://github.com/astral-sh/ruff
[`E402`] Allow cell magics before an import (#10545)
This commit is contained in:
parent
895d9df02f
commit
c447454111
|
|
@ -87,6 +87,37 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a51463ee-091c-44b4-9069-c03bf7e3bf83",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"import pathlib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0ddc937e-6c19-475f-b108-9405aa1af4f1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "285041d2-a76c-4ff3-8ff2-0131bbf66016",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"%%time\n",
|
||||
"import pathlib"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
|
|||
|
|
@ -365,6 +365,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
|
|||
self.semantic.flags |= SemanticModelFlags::MODULE_DOCSTRING_BOUNDARY;
|
||||
self.semantic.flags |= SemanticModelFlags::FUTURES_BOUNDARY;
|
||||
if !(self.semantic.seen_import_boundary()
|
||||
|| stmt.is_ipy_escape_command_stmt()
|
||||
|| helpers::is_assignment_to_a_dunder(stmt)
|
||||
|| helpers::in_nested_block(self.semantic.current_statements())
|
||||
|| imports::is_matplotlib_activation(stmt, self.semantic())
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ E402.ipynb:30:1: E402 Module level import not at top of cell
|
|||
|
|
||||
30 | import no_ok
|
||||
| ^^^^^^^^^^^^ E402
|
||||
31 |
|
||||
32 | %%time
|
||||
|
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue