Replace flake8 with ruff (#8184)

This commit is contained in:
Christian Clauss 2023-03-16 13:31:29 +01:00 committed by GitHub
parent c96241b5a5
commit 521fbca61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 20 additions and 19 deletions

View File

@ -81,11 +81,11 @@ We want your work to be readable by others; therefore, we encourage you to note
black . black .
``` ```
- All submissions will need to pass the test `flake8 . --ignore=E203,W503 --max-line-length=88` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request. - All submissions will need to pass the test `ruff .` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
```bash ```bash
python3 -m pip install flake8 # only required the first time python3 -m pip install ruff # only required the first time
flake8 . --ignore=E203,W503 --max-line-length=88 --show-source ruff .
``` ```
- Original code submission require docstrings or comments to describe your work. - Original code submission require docstrings or comments to describe your work.

View File

@ -20,7 +20,7 @@ class EqualLoudnessFilter:
samplerate, use with caution. samplerate, use with caution.
Code based on matlab implementation at https://bit.ly/3eqh2HU Code based on matlab implementation at https://bit.ly/3eqh2HU
(url shortened for flake8) (url shortened for ruff)
Target curve: https://i.imgur.com/3g2VfaM.png Target curve: https://i.imgur.com/3g2VfaM.png
Yulewalk response: https://i.imgur.com/J9LnJ4C.png Yulewalk response: https://i.imgur.com/J9LnJ4C.png

View File

@ -1,6 +1,6 @@
""" """
python/black : true psf/black : true
flake8 : passed ruff : passed
""" """
from __future__ import annotations from __future__ import annotations

View File

@ -4,8 +4,8 @@ Changing contrast with PIL
This algorithm is used in This algorithm is used in
https://noivce.pythonanywhere.com/ Python web app. https://noivce.pythonanywhere.com/ Python web app.
python/black: True psf/black: True
flake8 : True ruff : True
""" """
from PIL import Image from PIL import Image

View File

@ -1,7 +1,7 @@
""" """
References: wikipedia:square free number References: wikipedia:square free number
python/black : True psf/black : True
flake8 : True ruff : True
""" """
from __future__ import annotations from __future__ import annotations

View File

@ -1,8 +1,8 @@
""" """
References: https://en.wikipedia.org/wiki/M%C3%B6bius_function References: https://en.wikipedia.org/wiki/M%C3%B6bius_function
References: wikipedia:square free number References: wikipedia:square free number
python/black : True psf/black : True
flake8 : True ruff : True
""" """
from maths.is_square_free import is_square_free from maths.is_square_free import is_square_free

View File

@ -9,10 +9,10 @@ class LinearCongruentialGenerator:
""" """
# The default value for **seed** is the result of a function call which is not # The default value for **seed** is the result of a function call which is not
# normally recommended and causes flake8-bugbear to raise a B008 error. However, # normally recommended and causes ruff to raise a B008 error. However, in this case,
# in this case, it is accptable because `LinearCongruentialGenerator.__init__()` # it is accptable because `LinearCongruentialGenerator.__init__()` will only be
# will only be called once per instance and it ensures that each instance will # called once per instance and it ensures that each instance will generate a unique
# generate a unique sequence of numbers. # sequence of numbers.
def __init__(self, multiplier, increment, modulo, seed=int(time())): # noqa: B008 def __init__(self, multiplier, increment, modulo, seed=int(time())): # noqa: B008
""" """

View File

@ -56,6 +56,7 @@ select = [ # https://beta.ruff.rs/docs/rules
"W", # W: pycodestyle warnings "W", # W: pycodestyle warnings
"YTT", # YTT: year 2020 "YTT", # YTT: year 2020
] ]
show-source = true
target-version = "py311" target-version = "py311"
[tool.ruff.mccabe] # DO NOT INCREASE THIS VALUE [tool.ruff.mccabe] # DO NOT INCREASE THIS VALUE

View File

@ -54,9 +54,9 @@ def full_adder(
# The default value for **backend** is the result of a function call which is not # The default value for **backend** is the result of a function call which is not
# normally recommended and causes flake8-bugbear to raise a B008 error. However, # normally recommended and causes ruff to raise a B008 error. However, in this case,
# in this case, this is acceptable because `Aer.get_backend()` is called when the # this is acceptable because `Aer.get_backend()` is called when the function is defined
# function is defined and that same backend is then reused for all function calls. # and that same backend is then reused for all function calls.
def ripple_adder( def ripple_adder(