From fa83eff1f5f0faec4c32d1e7b4a31805577abe18 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Thu, 16 Mar 2023 12:22:44 +0100
Subject: [PATCH] Replace flake8 with ruff

---
 CONTRIBUTING.md                                   | 6 +++---
 audio_filters/equal_loudness_filter.py.broken.txt | 2 +-
 data_structures/binary_tree/red_black_tree.py     | 4 ++--
 digital_image_processing/change_contrast.py       | 4 ++--
 maths/is_square_free.py                           | 4 ++--
 maths/mobius_function.py                          | 4 ++--
 other/linear_congruential_generator.py            | 8 ++++----
 pyproject.toml                                    | 1 +
 quantum/ripple_adder_classic.py                   | 6 +++---
 9 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3ce5bd1edf68..6b6e4d21bfc7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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.
diff --git a/audio_filters/equal_loudness_filter.py.broken.txt b/audio_filters/equal_loudness_filter.py.broken.txt
index b9a3c50e1c33..88cba8533cf7 100644
--- a/audio_filters/equal_loudness_filter.py.broken.txt
+++ b/audio_filters/equal_loudness_filter.py.broken.txt
@@ -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
diff --git a/data_structures/binary_tree/red_black_tree.py b/data_structures/binary_tree/red_black_tree.py
index b50d75d33689..3ebc8d63939b 100644
--- a/data_structures/binary_tree/red_black_tree.py
+++ b/data_structures/binary_tree/red_black_tree.py
@@ -1,6 +1,6 @@
 """
-python/black : true
-flake8 : passed
+psf/black : true
+ruff : passed
 """
 from __future__ import annotations
 
diff --git a/digital_image_processing/change_contrast.py b/digital_image_processing/change_contrast.py
index 6a150400249f..7e49694708f8 100644
--- a/digital_image_processing/change_contrast.py
+++ b/digital_image_processing/change_contrast.py
@@ -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
diff --git a/maths/is_square_free.py b/maths/is_square_free.py
index 4134398d258b..08c70dc32c38 100644
--- a/maths/is_square_free.py
+++ b/maths/is_square_free.py
@@ -1,7 +1,7 @@
 """
 References: wikipedia:square free number
-python/black : True
-flake8 : True
+psf/black : True
+ruff : True
 """
 from __future__ import annotations
 
diff --git a/maths/mobius_function.py b/maths/mobius_function.py
index 4fcf35f21813..8abdc4cafcb4 100644
--- a/maths/mobius_function.py
+++ b/maths/mobius_function.py
@@ -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
diff --git a/other/linear_congruential_generator.py b/other/linear_congruential_generator.py
index 777ee6355b9b..c016310f9cfa 100644
--- a/other/linear_congruential_generator.py
+++ b/other/linear_congruential_generator.py
@@ -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
         """
diff --git a/pyproject.toml b/pyproject.toml
index 6552101d2faa..169c3a71ba6c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -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
diff --git a/quantum/ripple_adder_classic.py b/quantum/ripple_adder_classic.py
index c07757af7fff..b604395bc583 100644
--- a/quantum/ripple_adder_classic.py
+++ b/quantum/ripple_adder_classic.py
@@ -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(