mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:37 +00:00
Add tkinter
import convention (#5626)
## Summary Adds `import tkinter as tk` to the list of default import conventions. Closes #5620. ## Test Plan Added `tkinter` to test fixture. `cargo test`
This commit is contained in:
parent
38fa305f35
commit
ac2e374a5a
3 changed files with 56 additions and 30 deletions
|
@ -5,15 +5,18 @@ import matplotlib.pyplot # unconventional
|
||||||
import numpy # unconventional
|
import numpy # unconventional
|
||||||
import pandas # unconventional
|
import pandas # unconventional
|
||||||
import seaborn # unconventional
|
import seaborn # unconventional
|
||||||
|
import tkinter # unconventional
|
||||||
|
|
||||||
import altair as altr # unconventional
|
import altair as altr # unconventional
|
||||||
import matplotlib.pyplot as plot # unconventional
|
import matplotlib.pyplot as plot # 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 tkinter as tkr # unconventional
|
||||||
|
|
||||||
import altair as alt # conventional
|
import altair as alt # conventional
|
||||||
import matplotlib.pyplot as plt # conventional
|
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 tkinter as tk # conventional
|
||||||
|
|
|
@ -13,6 +13,7 @@ const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
||||||
("pandas", "pd"),
|
("pandas", "pd"),
|
||||||
("seaborn", "sns"),
|
("seaborn", "sns"),
|
||||||
("tensorflow", "tf"),
|
("tensorflow", "tf"),
|
||||||
|
("tkinter", "tk"),
|
||||||
("holoviews", "hv"),
|
("holoviews", "hv"),
|
||||||
("panel", "pn"),
|
("panel", "pn"),
|
||||||
("plotly.express", "px"),
|
("plotly.express", "px"),
|
||||||
|
@ -31,7 +32,7 @@ const CONVENTIONAL_ALIASES: &[(&str, &str)] = &[
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
#[option(
|
#[option(
|
||||||
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"}"#,
|
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"}"#,
|
||||||
value_type = "dict[str, str]",
|
value_type = "dict[str, str]",
|
||||||
example = r#"
|
example = r#"
|
||||||
[tool.ruff.flake8-import-conventions.aliases]
|
[tool.ruff.flake8-import-conventions.aliases]
|
||||||
|
|
|
@ -40,6 +40,7 @@ defaults.py:6:8: ICN001 `pandas` should be imported as `pd`
|
||||||
6 | import pandas # unconventional
|
6 | import pandas # unconventional
|
||||||
| ^^^^^^ ICN001
|
| ^^^^^^ ICN001
|
||||||
7 | import seaborn # unconventional
|
7 | import seaborn # unconventional
|
||||||
|
8 | import tkinter # unconventional
|
||||||
|
|
|
|
||||||
= help: Alias `pandas` to `pd`
|
= help: Alias `pandas` to `pd`
|
||||||
|
|
||||||
|
@ -49,62 +50,83 @@ defaults.py:7:8: ICN001 `seaborn` should be imported as `sns`
|
||||||
6 | import pandas # unconventional
|
6 | import pandas # unconventional
|
||||||
7 | import seaborn # unconventional
|
7 | import seaborn # unconventional
|
||||||
| ^^^^^^^ ICN001
|
| ^^^^^^^ ICN001
|
||||||
8 |
|
8 | import tkinter # unconventional
|
||||||
9 | import altair as altr # unconventional
|
|
||||||
|
|
|
|
||||||
= help: Alias `seaborn` to `sns`
|
= help: Alias `seaborn` to `sns`
|
||||||
|
|
||||||
defaults.py:9:18: ICN001 `altair` should be imported as `alt`
|
defaults.py:8:8: ICN001 `tkinter` should be imported as `tk`
|
||||||
|
|
|
|
||||||
|
6 | import pandas # unconventional
|
||||||
7 | import seaborn # unconventional
|
7 | import seaborn # unconventional
|
||||||
8 |
|
8 | import tkinter # unconventional
|
||||||
9 | import altair as altr # unconventional
|
| ^^^^^^^ ICN001
|
||||||
|
9 |
|
||||||
|
10 | import altair as altr # unconventional
|
||||||
|
|
|
||||||
|
= help: Alias `tkinter` to `tk`
|
||||||
|
|
||||||
|
defaults.py:10:18: ICN001 `altair` should be imported as `alt`
|
||||||
|
|
|
||||||
|
8 | import tkinter # unconventional
|
||||||
|
9 |
|
||||||
|
10 | import altair as altr # unconventional
|
||||||
| ^^^^ ICN001
|
| ^^^^ ICN001
|
||||||
10 | import matplotlib.pyplot as plot # unconventional
|
11 | import matplotlib.pyplot as plot # unconventional
|
||||||
11 | import numpy as nmp # unconventional
|
12 | import numpy as nmp # unconventional
|
||||||
|
|
|
|
||||||
= help: Alias `altair` to `alt`
|
= help: Alias `altair` to `alt`
|
||||||
|
|
||||||
defaults.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt`
|
defaults.py:11:29: ICN001 `matplotlib.pyplot` should be imported as `plt`
|
||||||
|
|
|
|
||||||
9 | import altair as altr # unconventional
|
10 | import altair as altr # unconventional
|
||||||
10 | import matplotlib.pyplot as plot # unconventional
|
11 | import matplotlib.pyplot as plot # unconventional
|
||||||
| ^^^^ ICN001
|
| ^^^^ ICN001
|
||||||
11 | import numpy as nmp # unconventional
|
12 | import numpy as nmp # unconventional
|
||||||
12 | import pandas as pdas # unconventional
|
13 | import pandas as pdas # unconventional
|
||||||
|
|
|
|
||||||
= help: Alias `matplotlib.pyplot` to `plt`
|
= help: Alias `matplotlib.pyplot` to `plt`
|
||||||
|
|
||||||
defaults.py:11:17: ICN001 `numpy` should be imported as `np`
|
defaults.py:12:17: ICN001 `numpy` should be imported as `np`
|
||||||
|
|
|
|
||||||
9 | import altair as altr # unconventional
|
10 | import altair as altr # unconventional
|
||||||
10 | import matplotlib.pyplot as plot # unconventional
|
11 | import matplotlib.pyplot as plot # unconventional
|
||||||
11 | import numpy as nmp # unconventional
|
12 | import numpy as nmp # unconventional
|
||||||
| ^^^ ICN001
|
| ^^^ ICN001
|
||||||
12 | import pandas as pdas # unconventional
|
13 | import pandas as pdas # unconventional
|
||||||
13 | import seaborn as sbrn # unconventional
|
14 | import seaborn as sbrn # unconventional
|
||||||
|
|
|
|
||||||
= help: Alias `numpy` to `np`
|
= help: Alias `numpy` to `np`
|
||||||
|
|
||||||
defaults.py:12:18: ICN001 `pandas` should be imported as `pd`
|
defaults.py:13:18: ICN001 `pandas` should be imported as `pd`
|
||||||
|
|
|
|
||||||
10 | import matplotlib.pyplot as plot # unconventional
|
11 | import matplotlib.pyplot as plot # unconventional
|
||||||
11 | import numpy as nmp # unconventional
|
12 | import numpy as nmp # unconventional
|
||||||
12 | import pandas as pdas # unconventional
|
13 | import pandas as pdas # unconventional
|
||||||
| ^^^^ ICN001
|
| ^^^^ ICN001
|
||||||
13 | import seaborn as sbrn # unconventional
|
14 | import seaborn as sbrn # unconventional
|
||||||
|
15 | import tkinter as tkr # unconventional
|
||||||
|
|
|
|
||||||
= help: Alias `pandas` to `pd`
|
= help: Alias `pandas` to `pd`
|
||||||
|
|
||||||
defaults.py:13:19: ICN001 `seaborn` should be imported as `sns`
|
defaults.py:14:19: ICN001 `seaborn` should be imported as `sns`
|
||||||
|
|
|
|
||||||
11 | import numpy as nmp # unconventional
|
12 | import numpy as nmp # unconventional
|
||||||
12 | import pandas as pdas # unconventional
|
13 | import pandas as pdas # unconventional
|
||||||
13 | import seaborn as sbrn # unconventional
|
14 | import seaborn as sbrn # unconventional
|
||||||
| ^^^^ ICN001
|
| ^^^^ ICN001
|
||||||
14 |
|
15 | import tkinter as tkr # unconventional
|
||||||
15 | import altair as alt # conventional
|
|
||||||
|
|
|
|
||||||
= help: Alias `seaborn` to `sns`
|
= help: Alias `seaborn` to `sns`
|
||||||
|
|
||||||
|
defaults.py:15:19: ICN001 `tkinter` should be imported as `tk`
|
||||||
|
|
|
||||||
|
13 | import pandas as pdas # unconventional
|
||||||
|
14 | import seaborn as sbrn # unconventional
|
||||||
|
15 | import tkinter as tkr # unconventional
|
||||||
|
| ^^^ ICN001
|
||||||
|
16 |
|
||||||
|
17 | import altair as alt # conventional
|
||||||
|
|
|
||||||
|
= help: Alias `tkinter` to `tk`
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue