Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to avoid ruff removing import hvplot... #1399

Open
MarcSkovMadsen opened this issue Aug 27, 2024 · 4 comments
Open

Document how to avoid ruff removing import hvplot... #1399

MarcSkovMadsen opened this issue Aug 27, 2024 · 4 comments
Labels

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Aug 27, 2024

We are migrating from pylint to ruff. ruff --fix --unsafe-fixes removes import hvplot.pandas as an unused import. See https://docs.astral.sh/ruff/rules/unused-import/.

I believe it would be very helpful for lots of users if this issue was discussed and solutions proposed in the docs.

One solution is to import hvplot.pandas # noqa: F401. But its rather painful to do across many files. I wish there was a more general solution.

@holoviz holoviz deleted a comment Aug 27, 2024
@hoxbro
Copy link
Member

hoxbro commented Aug 27, 2024

Running it with --unsafe-fixes can give unsafe fixes, which is what this is. Does the problem still happen without the --unsafe-fixes?

You can use extend-unsafe-fixes or unfixable in your settings file to avoid it being automatic removed.

It would be nice if Ruff had a whitelist option for some imports.

@MarcSkovMadsen
Copy link
Collaborator Author

Ruff is actually considering it a "safe" fix. I.e. its removed with ruff --fix.

@hoxbro
Copy link
Member

hoxbro commented Oct 4, 2024

In the next of release of Ruff (the one after 0.6.8), allow-unused-imports has been added.

We should find someplace to mention this in hvplot docs. hvplot.pandas will also be the example in Ruff docs around here.

[tool.ruff.lint.pyflakes]
allow-unused-imports = ["hvplot.pandas"]

@hoxbro
Copy link
Member

hoxbro commented Oct 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants