mirror of https://github.com/astral-sh/ruff
Extend conventional imports defaults to include TensorFlow et al (#2353)
extend conventional imports Based on configuration from Visual Studio for Python (https://code.visualstudio.com/docs/python/editing#_quick-fixes)
This commit is contained in:
parent
6798675db1
commit
50046fbed3
|
|
@ -2930,7 +2930,7 @@ allow-multiline = false
|
||||||
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` option.
|
the `extend_aliases` option.
|
||||||
|
|
||||||
**Default value**: `{"altair": "alt", "matplotlib.pyplot": "plt", "numpy": "np", "pandas": "pd", "seaborn": "sns"}`
|
**Default value**: `{"altair": "alt", "matplotlib": "mpl", "matplotlib.pyplot": "plt", "numpy": "np", "pandas": "pd", "seaborn": "sns", "tensorflow": "tf", "holoviews": "hv", "panel": "pn", "plotly.express": "px", "polars": "pl", "pyarrow": "pa"}`
|
||||||
|
|
||||||
**Type**: `FxHashMap<String, String>`
|
**Type**: `FxHashMap<String, String>`
|
||||||
|
|
||||||
|
|
@ -2945,6 +2945,7 @@ altair = "alt"
|
||||||
numpy = "np"
|
numpy = "np"
|
||||||
pandas = "pd"
|
pandas = "pd"
|
||||||
seaborn = "sns"
|
seaborn = "sns"
|
||||||
|
scripy = "sp"
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ import matplotlib.pyplot # unconventional
|
||||||
import numpy # unconventional
|
import numpy # unconventional
|
||||||
import pandas # unconventional
|
import pandas # unconventional
|
||||||
import seaborn # unconventional
|
import seaborn # unconventional
|
||||||
|
import tensorflow # unconventional
|
||||||
|
import holoviews # unconventional
|
||||||
|
import panel # unconventional
|
||||||
|
import plotly.express # unconventional
|
||||||
|
import matplotlib # unconventional
|
||||||
|
import polars # unconventional
|
||||||
|
import pyarrow # unconventional
|
||||||
|
|
||||||
import altair as altr # unconventional
|
import altair as altr # unconventional
|
||||||
import matplotlib.pyplot as plot # unconventional
|
import matplotlib.pyplot as plot # unconventional
|
||||||
|
|
@ -15,6 +22,13 @@ import dask.dataframe as ddf # unconventional
|
||||||
import numpy as nmp # unconventional
|
import numpy as nmp # unconventional
|
||||||
import pandas as pdas # unconventional
|
import pandas as pdas # unconventional
|
||||||
import seaborn as sbrn # unconventional
|
import seaborn as sbrn # unconventional
|
||||||
|
import tensorflow as tfz # unconventional
|
||||||
|
import holoviews as hsv # unconventional
|
||||||
|
import panel as pns # unconventional
|
||||||
|
import plotly.express as pltx # unconventional
|
||||||
|
import matplotlib as ml # unconventional
|
||||||
|
import polars as ps # unconventional
|
||||||
|
import pyarrow as arr # unconventional
|
||||||
|
|
||||||
import altair as alt # conventional
|
import altair as alt # conventional
|
||||||
import dask.array as da # conventional
|
import dask.array as da # conventional
|
||||||
|
|
@ -23,3 +37,12 @@ import matplotlib.pyplot as plt # conventional
|
||||||
import numpy as np # conventional
|
import numpy as np # conventional
|
||||||
import pandas as pd # conventional
|
import pandas as pd # conventional
|
||||||
import seaborn as sns # conventional
|
import seaborn as sns # conventional
|
||||||
|
import tensorflow as tf # conventional
|
||||||
|
import holoviews as hv # conventional
|
||||||
|
import panel as pn # conventional
|
||||||
|
import plotly.express as px # conventional
|
||||||
|
import matplotlib as mpl # conventional
|
||||||
|
import polars as pl # conventional
|
||||||
|
import pyarrow as pa # conventional
|
||||||
|
|
||||||
|
from tensorflow.keras import Model # conventional
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,17 @@ use crate::settings::hashable::HashableHashMap;
|
||||||
|
|
||||||
const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
||||||
("altair", "alt"),
|
("altair", "alt"),
|
||||||
|
("matplotlib", "mpl"),
|
||||||
("matplotlib.pyplot", "plt"),
|
("matplotlib.pyplot", "plt"),
|
||||||
("numpy", "np"),
|
("numpy", "np"),
|
||||||
("pandas", "pd"),
|
("pandas", "pd"),
|
||||||
("seaborn", "sns"),
|
("seaborn", "sns"),
|
||||||
|
("tensorflow", "tf"),
|
||||||
|
("holoviews", "hv"),
|
||||||
|
("panel", "pn"),
|
||||||
|
("plotly.express", "px"),
|
||||||
|
("polars", "pl"),
|
||||||
|
("pyarrow", "pa"),
|
||||||
];
|
];
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
@ -27,7 +34,7 @@ const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
||||||
)]
|
)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
#[option(
|
#[option(
|
||||||
default = r#"{"altair": "alt", "matplotlib.pyplot": "plt", "numpy": "np", "pandas": "pd", "seaborn": "sns"}"#,
|
default = r#"{"altair": "alt", "matplotlib": "mpl", "matplotlib.pyplot": "plt", "numpy": "np", "pandas": "pd", "seaborn": "sns", "tensorflow": "tf", "holoviews": "hv", "panel": "pn", "plotly.express": "px", "polars": "pl", "pyarrow": "pa"}"#,
|
||||||
value_type = "FxHashMap<String, String>",
|
value_type = "FxHashMap<String, String>",
|
||||||
example = r#"
|
example = r#"
|
||||||
[tool.ruff.flake8-import-conventions.aliases]
|
[tool.ruff.flake8-import-conventions.aliases]
|
||||||
|
|
@ -37,6 +44,7 @@ pub struct Options {
|
||||||
numpy = "np"
|
numpy = "np"
|
||||||
pandas = "pd"
|
pandas = "pd"
|
||||||
seaborn = "sns"
|
seaborn = "sns"
|
||||||
|
scripy = "sp"
|
||||||
"#
|
"#
|
||||||
)]
|
)]
|
||||||
/// The conventional aliases for imports. These aliases can be extended by
|
/// The conventional aliases for imports. These aliases can be extended by
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,97 @@ expression: diagnostics
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImportAliasIsNotConventional:
|
ImportAliasIsNotConventional:
|
||||||
- altair
|
- tensorflow
|
||||||
- alt
|
- tf
|
||||||
|
location:
|
||||||
|
row: 10
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 10
|
||||||
|
column: 17
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- holoviews
|
||||||
|
- hv
|
||||||
location:
|
location:
|
||||||
row: 11
|
row: 11
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 11
|
row: 11
|
||||||
|
column: 16
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- panel
|
||||||
|
- pn
|
||||||
|
location:
|
||||||
|
row: 12
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 12
|
||||||
|
column: 12
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- plotly.express
|
||||||
|
- px
|
||||||
|
location:
|
||||||
|
row: 13
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 13
|
||||||
|
column: 21
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- matplotlib
|
||||||
|
- mpl
|
||||||
|
location:
|
||||||
|
row: 14
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 14
|
||||||
|
column: 17
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- polars
|
||||||
|
- pl
|
||||||
|
location:
|
||||||
|
row: 15
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 15
|
||||||
|
column: 13
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- pyarrow
|
||||||
|
- pa
|
||||||
|
location:
|
||||||
|
row: 16
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 16
|
||||||
|
column: 14
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- altair
|
||||||
|
- alt
|
||||||
|
location:
|
||||||
|
row: 18
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 18
|
||||||
column: 21
|
column: 21
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -103,10 +187,10 @@ expression: diagnostics
|
||||||
- matplotlib.pyplot
|
- matplotlib.pyplot
|
||||||
- plt
|
- plt
|
||||||
location:
|
location:
|
||||||
row: 12
|
row: 19
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 12
|
row: 19
|
||||||
column: 32
|
column: 32
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -115,10 +199,10 @@ expression: diagnostics
|
||||||
- dask.array
|
- dask.array
|
||||||
- da
|
- da
|
||||||
location:
|
location:
|
||||||
row: 13
|
row: 20
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 13
|
row: 20
|
||||||
column: 27
|
column: 27
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -127,10 +211,10 @@ expression: diagnostics
|
||||||
- dask.dataframe
|
- dask.dataframe
|
||||||
- dd
|
- dd
|
||||||
location:
|
location:
|
||||||
row: 14
|
row: 21
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 14
|
row: 21
|
||||||
column: 28
|
column: 28
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -139,10 +223,10 @@ expression: diagnostics
|
||||||
- numpy
|
- numpy
|
||||||
- np
|
- np
|
||||||
location:
|
location:
|
||||||
row: 15
|
row: 22
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 15
|
row: 22
|
||||||
column: 19
|
column: 19
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -151,10 +235,10 @@ expression: diagnostics
|
||||||
- pandas
|
- pandas
|
||||||
- pd
|
- pd
|
||||||
location:
|
location:
|
||||||
row: 16
|
row: 23
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 16
|
row: 23
|
||||||
column: 21
|
column: 21
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
@ -163,11 +247,95 @@ expression: diagnostics
|
||||||
- seaborn
|
- seaborn
|
||||||
- sns
|
- sns
|
||||||
location:
|
location:
|
||||||
row: 17
|
row: 24
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 17
|
row: 24
|
||||||
column: 22
|
column: 22
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- tensorflow
|
||||||
|
- tf
|
||||||
|
location:
|
||||||
|
row: 25
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 25
|
||||||
|
column: 24
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- holoviews
|
||||||
|
- hv
|
||||||
|
location:
|
||||||
|
row: 26
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 26
|
||||||
|
column: 23
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- panel
|
||||||
|
- pn
|
||||||
|
location:
|
||||||
|
row: 27
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 27
|
||||||
|
column: 19
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- plotly.express
|
||||||
|
- px
|
||||||
|
location:
|
||||||
|
row: 28
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 28
|
||||||
|
column: 29
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- matplotlib
|
||||||
|
- mpl
|
||||||
|
location:
|
||||||
|
row: 29
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 29
|
||||||
|
column: 23
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- polars
|
||||||
|
- pl
|
||||||
|
location:
|
||||||
|
row: 30
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 30
|
||||||
|
column: 19
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
ImportAliasIsNotConventional:
|
||||||
|
- pyarrow
|
||||||
|
- pa
|
||||||
|
location:
|
||||||
|
row: 31
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 31
|
||||||
|
column: 21
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue