[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:
Mohammad Amin Ghasemi 2025-04-02 10:55:46 +03:30 committed by GitHub
parent f63024843c
commit e1b5b0de71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 1 deletions

View file

@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,

View file

@ -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,

View file

@ -46,3 +46,7 @@ import polars as pl # conventional
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

View file

@ -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"),

View file

@ -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`

View file

@ -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#"