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

Support ruff #511

Closed
mcarans opened this issue Mar 27, 2023 · 6 comments
Closed

Support ruff #511

mcarans opened this issue Mar 27, 2023 · 6 comments

Comments

@mcarans
Copy link

mcarans commented Mar 27, 2023

It would be great if autohooks could support ruff.

BTW, I think the fact that this tool uses pyproject.toml (unlike pre-commit) is a big plus that you could highlight in your documentation.

@bjoernricks
Copy link
Member

BTW, I think the fact that this tool uses pyproject.toml (unlike pre-commit) is a big plus that you could make highlight in your documentation.

That the reason why I did wrote autohooks. Using the standard pyproject.toml file and don't add another tool for installing dependencies. Thanks for the hint. I'll do that.

It would be great if autohooks could support ruff.

We didn't test ruff yet so we don't have any plans to implement a plugin at the moment.

But really it is very easy to write a plugin by yourself. Just take a look at the autohooks plugin for pylint too. It's just a few lines of code.

@mcarans
Copy link
Author

mcarans commented Apr 12, 2023

@bjoernricks Great that you updated the README - one of the main benefits of autohooks is clearer now.

I had a look at the pylint plugin but while it might be easy for you to write a new plugin, without some kind of documentation on how to write a plugin, I think it would not be easy for me to do it.

I think ruff support could be another selling point for this library given that ruff is becoming quite popular ("Ruff is extremely actively developed and used in major open-source projects like:

Apache Airflow
FastAPI
Hugging Face
Pandas
SciPy
...and many more.")

Since it replaces a bunch of linting tools, it would save writing several plugins. ("Ruff can be used to replace Flake8 (plus dozens of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool.")

I expect it will become the default linter of most projects replacing flake8, pylint etc. so support for it might provide a boost for this project.

@bjoernricks
Copy link
Member

You never know what the future will bring. I've seen tools coming and leaving. At the moment we at Greenbone aren't using ruff. Thus maintaining a plugin for it is a burden and wont happen in near future. Writing a peace of software is the easy part. Maintaining it is the hard work. If there is somebody willing to maintain a ruff plugin now I can assist in writing the plugin.

without some kind of documentation on how to write a plugin

Actually there is a documentation on how to write a plugin see https://greenbone.github.io/autohooks/create.html

I had a look at the pylint plugin

When looking at the pylint plugin you nearly only need to replace all occurrences of pylint with ruff and it will work.

@mcarans
Copy link
Author

mcarans commented Apr 12, 2023

Ah I missed that documentation. How do you test the plugin without publishing it to pypi? For example, to test the pylint plugin, would you copy the autohooks/plugins/pylint/ folder to .autohooks of the Git repo you want to test it with keeping the folder structure (ie. .autohooks/autohooks/plugins/pylint/)?

@bjoernricks
Copy link
Member

Personally I would use an editable install pip install -e /path/to/autohooks/plugin in a virtual environment. See https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs for more details.

@mcarans
Copy link
Author

mcarans commented May 26, 2023

In a discussion on the Python.org forums, Python core devs said they think pyproject.toml is being overused by tools so my colleague has begun switching our projects to having tool configuration in a .config folder, so I'll close this issue as no longer needed (at least by me).

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

No branches or pull requests

2 participants