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

Proposal: use ruff to replace flake8 and related extensions #1282

Open
cauliyang opened this issue Dec 27, 2022 · 15 comments
Open

Proposal: use ruff to replace flake8 and related extensions #1282

cauliyang opened this issue Dec 27, 2022 · 15 comments

Comments

@cauliyang
Copy link
Contributor

Now ruff is blazing fast linter than flake8. Its rules are self contained and it is evolving quickly so far. Currently it has covered most useful rules. I think we can keep an eye on it and move to ruff at proper time. What do you think?

@cauliyang cauliyang changed the title Proposal: use ruff to replace flake8 and related plugins Proposal: use ruff to replace flake8 and related extensions Dec 27, 2022
@joelb123
Copy link

joelb123 commented Apr 5, 2023

I strongly agree. Not only is it faster, the list of modules that would get replaced, AFAIK is:

  • bandit
  • flake8-bugbear
  • flake8-docstrings
  • flake8-rst-docstrings
  • isort
  • pep8-naming
  • pydocstyle
  • pyupgrade

In addition, there's more out-of-the-box functionality (e.g. pandas-vet for us pandas users).

@bmritz
Copy link

bmritz commented Apr 26, 2023

@joelb123 @cauliyang do you know of any forks that use ruff? I have a fork at https://github.com/bmritz/cookiecutter-hypermodern-python that I was thinking about putting ruff into, but if there's a reference I could go off of, that would be helpful.

EDIT: here's one: https://github.com/dbatten5/cookiecutter-hypermodern-python. And here is the relevant commit: dbatten5@327b373

@joelb123
Copy link

Yes, I saw the @dbatten5 commit, but I haven't looked at it in detail. I did notice that this fork kept 'isort', which is a pity since getting rid of fighting with 'isort' is one of the many good things about ruff.

Because ruff is so performant and has '--fix' for many issues, it can enable checks/fixes with every save by the IDE (e.g., via the pycharm ruff plugin). This means more productivity for those who use ruff, but it also means more boilerplate in 'pyproject.toml'.

@dbatten5
Copy link

dbatten5 commented Apr 26, 2023

I couldn't really get ruff working without isort the same as when I had isort. Would be happy to get rid of it though and run everything through ruff - do you have an example config for ruff replacing the need for isort @joelb123 ?

EDIT: Got there in the end dbatten5@68dbd7d . Was having a little trouble with autodetection of first party imports so ended up having to go with src = ['src', 'tests'] under [tool.ruff].

@bosd
Copy link

bosd commented Feb 27, 2024

Does anyone have ruff running succesfully and able to open a PR in this repo?

@dbatten5
Copy link

I have it running in my fork https://github.com/dbatten5/cookiecutter-hypermodern-python. Should be able to open a PR in the near future

@aeturrell
Copy link

I think this would be a great change, not sure if anyone has put in a PR for it yet?

@bruno-fs
Copy link

I'm working on replacing all compatible linters with ruff on my fork. The only things I didn't replace yet are darglint and flake8-rst-docstrings. I'm not sure how to handle them. I also replaced black with ruff format.

Given darglint was archived, I wonder if it is still relevant. But there's an open issue for it on ruff repo. However, flake8-rst-docstrings don't have an open discussion there.

@webknjaz
Copy link

There's darglint2 per https://softwarerecs.stackexchange.com/a/86925/61183, additionally, there's a pylint plugin with similar features. There's a similar flake8 integration in https://github.com/jsh9/pydoclint which is promised to be faster. The latter was actually offered in the issue mentioned above.

@bruno-fs
Copy link

@webknjaz Thanks for pointing that out! I'm impressed with pydoclint speed!

bruno-fs added a commit to bruno-fs/retrocookie-hypermodern-python that referenced this issue May 28, 2024
As highlighted [here][github discussion], pydoclint is a much faster
alternative.

[github discussion]: cjolowicz/cookiecutter-hypermodern-python#1282 (comment)
bruno-fs added a commit to bruno-fs/retrocookie-hypermodern-python that referenced this issue May 28, 2024
As highlighted [here][github discussion], pydoclint is a much faster
alternative.

[github discussion]: cjolowicz/cookiecutter-hypermodern-python#1282 (comment)
bruno-fs added a commit to bruno-fs/cookiecutter-hypermodern-python that referenced this issue May 28, 2024
As highlighted [here][github discussion], pydoclint is a much faster
alternative.

[github discussion]: cjolowicz#1282 (comment)
bruno-fs added a commit to bruno-fs/cookiecutter-hypermodern-python that referenced this issue May 29, 2024
As highlighted [here][github discussion], pydoclint is a much faster
alternative.

[github discussion]: cjolowicz#1282 (comment)
@bosd
Copy link

bosd commented Aug 9, 2024

@bruno-fs Your fork looks really interesting. Any plans to contribute and open a PR here? 🙏

@bruno-fs
Copy link

bruno-fs commented Aug 9, 2024

Thanks, @bosd. I'm using it in some projects.

I do plan to open a PR, but aaaaaaaaaall the documentation still needs to be updated and I have other priorities atm.

Also, I went a little bit further and stripped away flake8-rst-docstrings and replaced darglint with pydoclint, which might be seem as controversial moves.

Furthermore, I'm also on the verge of removing poetry.lock from the template, because it is a constant source of conflicts in my workflow, which relies on cruft .

@bosd
Copy link

bosd commented Aug 11, 2024

@bruno-fs Thanks, your fork looks really interesting.
Specifically the cruft.
Personally I like it, but it might be too opinionated for the projects i'm working with.

@bruno-fs
Copy link

@bosd cruft is not on the fork, I'm just using it to consume the template instead of using cookiecutter itself :D

But replacing linters with ruff already is an opinionated move. The author might not even accept a PR. What are your thoughts on this matter, @cjolowicz?

Would you accept a PR replacing python linters with ruff? If so, I could create a branch with a cleanup version of my fork, only replacing the linters. I'd probably need help from someone interested to also update the documentation. That part is lacking in my fork.

@bosd
Copy link

bosd commented Nov 27, 2024

I even want a step further.
My fork is based on the one of bruon-fs.
Replacing poetry with uv.
https://github.com/bosd/cookiecutter-uv-hypermodern-python

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

8 participants