python-stdnum
python-stdnum copied to clipboard
Run `ruff` and fix issues?
Would you be willing to fix issues reported by ruff?
$ ruff --ignore 'E501,F405,F403' .
docs/conf.py:14:1: E401 Multiple imports on one line
docs/conf.py:14:8: F401 [*] `sys` imported but unused
docs/conf.py:14:13: F401 [*] `os` imported but unused
stdnum/ec/ci.py:50:5: E731 [*] Do not assign a `lambda` expression, use a `def`
stdnum/nz/bankaccount.py:94:42: E741 Ambiguous variable name: `l`
stdnum/pt/cc.py:64:5: E731 [*] Do not assign a `lambda` expression, use a `def`
Found 6 errors.
[*] 4 potentially fixable with the --fix option.
$
From a pitch seen elsewhere: "Ruff supports over 500 lint rules including bandit, isort, pylint, pyupgrade, and flake8 plus its plugins and is written in Rust for speed".
I could start by fixing these issues, and then maybe attempt to move CI tests to ruff instead of flake8.
I've had a quick look a while back and here are some random thoughts.
- I'm not that happy with the recent changes in flake8 (breaking existing configuration and refusing discussion about it) so I'm open to alternatives
- I find it a bit weird that ruff is written in Rust: it says that you can't or shouldn't implement Python linting tools in Python :confused:
- the primary advertised selling point of ruff is the speed improvement but I've never considered flake8 to be slow (pylint yes but flake8 no)
- it does not support Python 2.7 code without a lot of tweaking
- I like the fix ability (but by default it makes changes that means that my code no longer works with older Python versions)
- I really like the concept of flake8 to have plugins that can easily extend the checks that are done and the freedom of choice it brings
- I have some concerns regarding the stability of ruff given the large number of releases (currently version 0.0.272)
I'll probably look into this more sometime soon and see if I can integrate some of the improvements suggested by ruff.
The only stability issue is that ruff breaks CI from time to time because of new rules, unless of course you pin it down to a very specific version. The core program is stable in my short experience, but the ever increasing set of rules is a pain.
I must admit, I hadn't thought about Python 2.7.
Finally, don't see Rust as a problem, as installation involves a mere pip install ruff
.