mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
[flake8-import-conventions] Add import numpy.typing as npt
to default flake8-import-conventions.aliases
(#17133)
## Summary Adds import `numpy.typing as npt` to `default in flake8-import-conventions.aliases` Resolves #17028 ## Test Plan Manually ran local ruff on the altered fixture and also ran `cargo test`
This commit is contained in:
parent
f63024843c
commit
e1b5b0de71
6 changed files with 35 additions and 1 deletions
|
@ -2244,6 +2244,7 @@ requires-python = ">= 3.11"
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -2554,6 +2555,7 @@ requires-python = ">= 3.11"
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -2916,6 +2918,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -3294,6 +3297,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -3620,6 +3624,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -3946,6 +3951,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -4229,6 +4235,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
@ -4565,6 +4572,7 @@ from typing import Union;foo: Union[int, str] = 1
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
|
|
@ -250,6 +250,7 @@ linter.flake8_import_conventions.aliases = {
|
||||||
matplotlib.pyplot = plt,
|
matplotlib.pyplot = plt,
|
||||||
networkx = nx,
|
networkx = nx,
|
||||||
numpy = np,
|
numpy = np,
|
||||||
|
numpy.typing = npt,
|
||||||
pandas = pd,
|
pandas = pd,
|
||||||
panel = pn,
|
panel = pn,
|
||||||
plotly.express = px,
|
plotly.express = px,
|
||||||
|
|
|
@ -46,3 +46,7 @@ import polars as pl # conventional
|
||||||
import pyarrow as pa # conventional
|
import pyarrow as pa # conventional
|
||||||
|
|
||||||
from tensorflow.keras import Model # conventional
|
from tensorflow.keras import Model # conventional
|
||||||
|
|
||||||
|
import numpy.typing # unconventional
|
||||||
|
import numpy.typing as nt # unconventional
|
||||||
|
import numpy.typing as npt # conventional
|
|
@ -15,6 +15,7 @@ const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
||||||
("matplotlib.pyplot", "plt"),
|
("matplotlib.pyplot", "plt"),
|
||||||
("networkx", "nx"),
|
("networkx", "nx"),
|
||||||
("numpy", "np"),
|
("numpy", "np"),
|
||||||
|
("numpy.typing", "npt"),
|
||||||
("pandas", "pd"),
|
("pandas", "pd"),
|
||||||
("seaborn", "sns"),
|
("seaborn", "sns"),
|
||||||
("tensorflow", "tf"),
|
("tensorflow", "tf"),
|
||||||
|
|
|
@ -304,3 +304,23 @@ custom.py:31:19: ICN001 `pyarrow` should be imported as `pa`
|
||||||
33 | import altair as alt # conventional
|
33 | import altair as alt # conventional
|
||||||
|
|
|
|
||||||
= help: Alias `pyarrow` to `pa`
|
= 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`
|
||||||
|
|
|
@ -1496,7 +1496,7 @@ pub struct Flake8ImportConventionsOptions {
|
||||||
/// The conventional aliases for imports. These aliases can be extended by
|
/// The conventional aliases for imports. These aliases can be extended by
|
||||||
/// the [`extend-aliases`](#lint_flake8-import-conventions_extend-aliases) option.
|
/// the [`extend-aliases`](#lint_flake8-import-conventions_extend-aliases) option.
|
||||||
#[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]",
|
value_type = "dict[str, str]",
|
||||||
scope = "aliases",
|
scope = "aliases",
|
||||||
example = r#"
|
example = r#"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue