Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/ruff/tests/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,7 @@ requires-python = ">= 3.11"
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -2554,6 +2555,7 @@ requires-python = ">= 3.11"
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -2916,6 +2918,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -3294,6 +3297,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -3620,6 +3624,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -3946,6 +3951,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -4229,6 +4235,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down Expand Up @@ -4565,6 +4572,7 @@ from typing import Union;foo: Union[int, str] = 1
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ linter.flake8_import_conventions.aliases = {
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
numpy.typing = npt,
pandas = pd,
panel = pn,
plotly.express = px,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
import pyarrow as pa # conventional

from tensorflow.keras import Model # conventional

import numpy.typing # unconventional
import numpy.typing as nt # unconventional
import numpy.typing as npt # conventional
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
("matplotlib.pyplot", "plt"),
("networkx", "nx"),
("numpy", "np"),
("numpy.typing", "npt"),
("pandas", "pd"),
("seaborn", "sns"),
("tensorflow", "tf"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,23 @@ custom.py:31:19: ICN001 `pyarrow` should be imported as `pa`
33 | import altair as alt # conventional
|
= help: Alias `pyarrow` to `pa`

custom.py:50:8: ICN001 `numpy.typing` should be imported as `npt`
|
48 | from tensorflow.keras import Model # conventional
49 |
50 | import numpy.typing # unconventional
| ^^^^^^^^^^^^ ICN001
51 | import numpy.typing as nt # unconventional
52 | import numpy.typing as npt # conventional
|
= help: Alias `numpy.typing` to `npt`

custom.py:51:24: ICN001 `numpy.typing` should be imported as `npt`
|
50 | import numpy.typing # unconventional
51 | import numpy.typing as nt # unconventional
| ^^ ICN001
52 | import numpy.typing as npt # conventional
|
= help: Alias `numpy.typing` to `npt`
2 changes: 1 addition & 1 deletion crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ pub struct Flake8ImportConventionsOptions {
/// The conventional aliases for imports. These aliases can be extended by
/// the [`extend-aliases`](#lint_flake8-import-conventions_extend-aliases) option.
#[option(
default = r#"{"altair": "alt", "matplotlib": "mpl", "matplotlib.pyplot": "plt", "numpy": "np", "pandas": "pd", "seaborn": "sns", "tensorflow": "tf", "tkinter": "tk", "holoviews": "hv", "panel": "pn", "plotly.express": "px", "polars": "pl", "pyarrow": "pa", "xml.etree.ElementTree": "ET"}"#,
default = r#"{"altair": "alt", "matplotlib": "mpl", "matplotlib.pyplot": "plt", "numpy": "np", "numpy.typing": "npt", "pandas": "pd", "seaborn": "sns", "tensorflow": "tf", "tkinter": "tk", "holoviews": "hv", "panel": "pn", "plotly.express": "px", "polars": "pl", "pyarrow": "pa", "xml.etree.ElementTree": "ET"}"#,
value_type = "dict[str, str]",
scope = "aliases",
example = r#"
Expand Down
Loading