Repository: astral-sh/ruff (Rust)

Issue:
`unconventional-import-alias (ICN001)`: Add `import numpy.typing as npt` to default `lint.flake8-import-conventions.aliases`
### Summary

[lint.flake8-import-conventions.aliases](https://docs.astral.sh/ruff/settings/#lint_flake8-import-conventions_aliases) already has `import numpy as np` but not `import numpy.typing as npt` which you can see in https://numpy.org/doc/stable/reference/typing.html is part of the numpy import alias convention.


Discussion:

Patch:
diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs
index 1692107a13f01a..f00406de4a1816 100644
--- a/crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs
+++ b/crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs
@@ -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"),
diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs
index e3a473b94dd875..a549ab909351c6 100644
--- a/crates/ruff_workspace/src/options.rs
+++ b/crates/ruff_workspace/src/options.rs
@@ -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#"


Test patch:
diff --git a/crates/ruff/tests/lint.rs b/crates/ruff/tests/lint.rs
index b95b99d93487d4..41b44d52923516 100644
--- a/crates/ruff/tests/lint.rs
+++ b/crates/ruff/tests/lint.rs
@@ -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,
diff --git a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap
index 7fe041a00d69b7..c404d07c8cd1f8 100644
--- a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap
+++ b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap
@@ -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,
diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py
index 09af781b2c5e10..32c624041397c0 100644
--- a/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py
+++ b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py
@@ -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
\ No newline at end of file
diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap
index dc6fb5571355b4..bae5ffd77ecbe5 100644
--- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap
+++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap
@@ -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`