arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
484 stars 203 forks source link

Run `ruff` and fix issues? #410

Open DimitriPapadopoulos opened 1 year ago

DimitriPapadopoulos commented 1 year ago

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.

arthurdejong commented 1 year ago

I've had a quick look a while back and here are some random thoughts.

I'll probably look into this more sometime soon and see if I can integrate some of the improvements suggested by ruff.

DimitriPapadopoulos commented 1 year ago

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.