Open MartinBernstorff opened 4 months ago
ruff --show-settings
shows me
linter.flake8_import_conventions.aliases = {
altair = alt,
holoviews = hv,
matplotlib = mpl,
matplotlib.pyplot = plt,
networkx = nx,
numpy = np,
pandas = pd,
panel = pn,
plotly.express = px,
polars = pl,
pyarrow = pa,
seaborn = sns,
tensorflow = tf,
tkinter = tk,
}
Does that help?
This is pretty nice, thanks! It supports part of, but not all of the workflow. What I would love to be able to do is:
1) Write some code, e.g. pl.DataFrame({"col1": [1,2,3})
2) Ruff detects a missing import for pl
.
3) Because pl
is in the list of "known imports", it is automatically added to the top of the file as import polars as pl
VSCode has some of this functionality, but AFAICT, you cannot add your own rules: https://dev.to/krisplatis/auto-add-missing-imports-on-file-save-in-vs-code-1b89
AFAICT, flake8_import_conventions does not automatically add the import.
I have a handful of imports that are always under the same alias, e.g.:
I would love if Ruff could detect a missing import and, if it matches any of a set of patterns specified in settings, auto-add the corresponding import.
Is this possible with the current feature set? Or could it be added? Love to hear what you think!