-
-
Notifications
You must be signed in to change notification settings - Fork 933
switch to Ruff instead of flake8
#1861
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
Comments
Thanks! CC @EliahKagan , who has been contemplating with the idea as well. |
Does it mean that PR is welcome? =) |
Let's wait for @EliahKagan to chime in on this, he has been doing a lot of work recently and has a plan. I say Rust tools are great, but I am biased ;). |
Yes, I think this is a great time to switch to Ruff. The main problem I encountered last time I worked on this is that Ruff didn't understand the special semantics of
Special rules are required to distinguish between them. Static type checkers such as My recollection is that this particular check is one that seems quite valuable for GitPython to have, and that flake8 is currently managing to provide it, without the false positives Ruff gives (or at least, at that time, gave). I am reluctant to disable it. Suppression comments could maybe be used, if they can be made narrow enough. I vaguely (and perhaps wrongly) recall that this seemed unwieldy to do at the time. An obvious possible solution is for GitPython to drop support for Python 3.7, since I am, however, biased in this area, because a feature branch I'm working on (that is related to symlinks on Windows and does not yet have a PR, and which I hope to pick back up after #1859) benefits from the continued inclusion of 3.7, in that 3.7 and later versions of Python differ in their handling of symlinks in a way that reveals weaknesses in the approach I am taking that would still be weaknesses even in the absence of a need to support 3.7. This is to say that, ironically, it benefits from 3.7 because it is hard to support 3.7. I acknowledge that "We should keep 3.7 support for a while longer because it is causing problems" is not a very strong argument. 😸 In spite of this, the reason I say now is a good time to switch to Ruff is that a long-standing flake8-related limitation has come up, relating to its interaction with black. The version of black that will automatically be installed with Unlike the rule at stake with Because Ruff at least previously had an issue with GitPython's use of |
in different projects, we used to use |
Yes, that may be the way to go. Depending how it is done, it could require adding However, when a type checker is installed and used, I believe This may be a little cumbersome for |
The conditional imports of Literal from either typing or typing_extensions have to be done with if-else on the Python version rather than with try-except, or it is a static type error. This makes that change, checking sys.version_info. (See discussion in gitpython-developers#1861 and gitpython-developers#1862 for broader context and background on why this logic, before and after this change, is repeated across multiple modules.) This also reorders/regroups imports for consistency in some places, especially where a new import of the sys module (for version_info) would otherwise exacerbate inconsistency. Since the merge commit 0b99041, the number of mypy errors had increased from 5 to 10. This fixes all the new mypy errors, so the count is back to 5.
Is your feature request related to a current problem? Please describe.
It would address linting speed, as Ruff is much faster and eventually extensibility, as Ruff can cover multiple linting packages with almost no performance drop...
Describe the proposed solution
replace linking with
flake8
, preserving the same configurationAdditional context
Recently Ruff has become very popular among also mainstream projects for:
isort
orbandit
The text was updated successfully, but these errors were encountered: