Skip to content

Commit

Permalink
Replace flake8 with ruff (TheAlgorithms#8184)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Mar 16, 2023
1 parent c96241b commit 521fbca
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ We want your work to be readable by others; therefore, we encourage you to note
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
python3 -m pip install flake8 # only required the first time
flake8 . --ignore=E203,W503 --max-line-length=88 --show-source
python3 -m pip install ruff # only required the first time
ruff .
```

- Original code submission require docstrings or comments to describe your work.
Expand Down
2 changes: 1 addition & 1 deletion audio_filters/equal_loudness_filter.py.broken.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EqualLoudnessFilter:
samplerate, use with caution.

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
Yulewalk response: https://i.imgur.com/J9LnJ4C.png
Expand Down
4 changes: 2 additions & 2 deletions data_structures/binary_tree/red_black_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
python/black : true
flake8 : passed
psf/black : true
ruff : passed
"""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions digital_image_processing/change_contrast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
This algorithm is used in
https://noivce.pythonanywhere.com/ Python web app.
python/black: True
flake8 : True
psf/black: True
ruff : True
"""

from PIL import Image
Expand Down
4 changes: 2 additions & 2 deletions maths/is_square_free.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
References: wikipedia:square free number
python/black : True
flake8 : True
psf/black : True
ruff : True
"""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions maths/mobius_function.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
References: https://en.wikipedia.org/wiki/M%C3%B6bius_function
References: wikipedia:square free number
python/black : True
flake8 : True
psf/black : True
ruff : True
"""

from maths.is_square_free import is_square_free
Expand Down
8 changes: 4 additions & 4 deletions other/linear_congruential_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class LinearCongruentialGenerator:
"""

# 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,
# in this case, it is accptable because `LinearCongruentialGenerator.__init__()`
# will only be called once per instance and it ensures that each instance will
# generate a unique sequence of numbers.
# normally recommended and causes ruff to raise a B008 error. However, in this case,
# it is accptable because `LinearCongruentialGenerator.__init__()` will only be
# called once per instance and it ensures that each instance will generate a unique
# sequence of numbers.

def __init__(self, multiplier, increment, modulo, seed=int(time())): # noqa: B008
"""
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ select = [ # https://beta.ruff.rs/docs/rules
"W", # W: pycodestyle warnings
"YTT", # YTT: year 2020
]
show-source = true
target-version = "py311"

[tool.ruff.mccabe] # DO NOT INCREASE THIS VALUE
Expand Down
6 changes: 3 additions & 3 deletions quantum/ripple_adder_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def full_adder(


# 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,
# in this case, this is acceptable because `Aer.get_backend()` is called when the
# function is defined and that same backend is then reused for all function calls.
# normally recommended and causes ruff to raise a B008 error. However, in this case,
# this is acceptable because `Aer.get_backend()` is called when the function is defined
# and that same backend is then reused for all function calls.


def ripple_adder(
Expand Down

0 comments on commit 521fbca

Please sign in to comment.