Skip to content

Commit 4d0c830

Browse files
CaedenPHcclausspre-commit-ci[bot]dhruvmanila
authored
Add flake8 pluin flake8 bugbear to pre-commit (TheAlgorithms#7132)
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (TheAlgorithms#7104) * refactor: Fix ``flake8-builtins`` (TheAlgorithms#7104) * fix(lru_cache): Fix naming conventions in docstrings (TheAlgorithms#7104) * ci(pre-commit): Order additional dependencies alphabetically (TheAlgorithms#7104) * fix(lfu_cache): Correct function name in docstring (TheAlgorithms#7104) * Update strings/snake_case_to_camel_pascal_case.py Co-authored-by: Christian Clauss <[email protected]> * Update data_structures/stacks/next_greater_element.py Co-authored-by: Christian Clauss <[email protected]> * Update digital_image_processing/index_calculation.py Co-authored-by: Christian Clauss <[email protected]> * Update graphs/prim.py Co-authored-by: Christian Clauss <[email protected]> * Update hashes/djb2.py Co-authored-by: Christian Clauss <[email protected]> * refactor: Rename `_builtin` to `builtin_` ( TheAlgorithms#7104) * fix: Rename all instances (TheAlgorithms#7104) * refactor: Update variable names (TheAlgorithms#7104) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ci: Create ``tox.ini`` and ignore ``A003`` (TheAlgorithms#7123) * revert: Remove function name changes (TheAlgorithms#7104) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Rename tox.ini to .flake8 * Update data_structures/heap/heap.py Co-authored-by: Dhruv Manilawala <[email protected]> * refactor: Rename `next_` to `next_item` (TheAlgorithms#7104) * ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (TheAlgorithms#7127) * refactor: Follow `flake8-bugbear` plugin (TheAlgorithms#7127) * fix: Correct `knapsack` code (TheAlgorithms#7127) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <[email protected]>
1 parent f176786 commit 4d0c830

File tree

71 files changed

+137
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+137
-124
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ repos:
4040
- --ignore=E203,W503
4141
- --max-complexity=25
4242
- --max-line-length=88
43-
additional_dependencies: [flake8-builtins, pep8-naming]
43+
additional_dependencies:
44+
- flake8-bugbear
45+
- flake8-builtins
46+
- pep8-naming
4447

4548
- repo: https://github.com/pre-commit/mirrors-mypy
4649
rev: v0.982

arithmetic_analysis/jacobi_iteration_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def jacobi_iteration_method(
110110
strictly_diagonally_dominant(table)
111111

112112
# Iterates the whole matrix for given number of times
113-
for i in range(iterations):
113+
for _ in range(iterations):
114114
new_val = []
115115
for row in range(rows):
116116
temp = 0

arithmetic_analysis/newton_forward_interpolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def ucal(u: float, p: int) -> float:
2323
def main() -> None:
2424
n = int(input("enter the numbers of values: "))
2525
y: list[list[float]] = []
26-
for i in range(n):
26+
for _ in range(n):
2727
y.append([])
2828
for i in range(n):
2929
for j in range(n):

arithmetic_analysis/secant_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def secant_method(lower_bound: float, upper_bound: float, repeats: int) -> float
2020
"""
2121
x0 = lower_bound
2222
x1 = upper_bound
23-
for i in range(0, repeats):
23+
for _ in range(0, repeats):
2424
x0, x1 = x1, x1 - (f(x1) * (x1 - x0)) / (f(x1) - f(x0))
2525
return x1
2626

audio_filters/butterworth_filter.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def make_lowpass(
14-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
14+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
1515
) -> IIRFilter:
1616
"""
1717
Creates a low-pass filter
@@ -39,7 +39,7 @@ def make_lowpass(
3939

4040

4141
def make_highpass(
42-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
42+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
4343
) -> IIRFilter:
4444
"""
4545
Creates a high-pass filter
@@ -67,7 +67,7 @@ def make_highpass(
6767

6868

6969
def make_bandpass(
70-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
70+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
7171
) -> IIRFilter:
7272
"""
7373
Creates a band-pass filter
@@ -96,7 +96,7 @@ def make_bandpass(
9696

9797

9898
def make_allpass(
99-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
99+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
100100
) -> IIRFilter:
101101
"""
102102
Creates an all-pass filter
@@ -121,7 +121,10 @@ def make_allpass(
121121

122122

123123
def make_peak(
124-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
124+
frequency: int,
125+
samplerate: int,
126+
gain_db: float,
127+
q_factor: float = 1 / sqrt(2), # noqa: B008
125128
) -> IIRFilter:
126129
"""
127130
Creates a peak filter
@@ -150,7 +153,10 @@ def make_peak(
150153

151154

152155
def make_lowshelf(
153-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
156+
frequency: int,
157+
samplerate: int,
158+
gain_db: float,
159+
q_factor: float = 1 / sqrt(2), # noqa: B008
154160
) -> IIRFilter:
155161
"""
156162
Creates a low-shelf filter
@@ -184,7 +190,10 @@ def make_lowshelf(
184190

185191

186192
def make_highshelf(
187-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
193+
frequency: int,
194+
samplerate: int,
195+
gain_db: float,
196+
q_factor: float = 1 / sqrt(2), # noqa: B008
188197
) -> IIRFilter:
189198
"""
190199
Creates a high-shelf filter

backtracking/sum_of_subsets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def create_state_space_tree(
3939
if sum(path) == max_sum:
4040
result.append(path)
4141
return
42-
for num_index in range(num_index, len(nums)):
42+
for index in range(num_index, len(nums)):
4343
create_state_space_tree(
4444
nums,
4545
max_sum,
46-
num_index + 1,
47-
path + [nums[num_index]],
46+
index + 1,
47+
path + [nums[index]],
4848
result,
49-
remaining_nums_sum - nums[num_index],
49+
remaining_nums_sum - nums[index],
5050
)
5151

5252

boolean_algebra/quine_mc_cluskey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def decimal_to_binary(no_of_variable: int, minterms: Sequence[float]) -> list[st
5656
temp = []
5757
for minterm in minterms:
5858
string = ""
59-
for i in range(no_of_variable):
59+
for _ in range(no_of_variable):
6060
string = str(minterm % 2) + string
6161
minterm //= 2
6262
temp.append(string)

ciphers/mixed_keyword_cypher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str:
4040
k = 0
4141
for _ in range(r):
4242
s = []
43-
for j in range(len_temp):
43+
for _ in range(len_temp):
4444
s.append(temp[k])
4545
if not (k < 25):
4646
break

ciphers/rabin_miller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def rabin_miller(num: int) -> bool:
1111
s = s // 2
1212
t += 1
1313

14-
for trials in range(5):
14+
for _ in range(5):
1515
a = random.randrange(2, num - 1)
1616
v = pow(a, s, num)
1717
if v != 1:

compression/burrows_wheeler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def reverse_bwt(bwt_string: str, idx_original_string: int) -> str:
154154
)
155155

156156
ordered_rotations = [""] * len(bwt_string)
157-
for x in range(len(bwt_string)):
157+
for _ in range(len(bwt_string)):
158158
for i in range(len(bwt_string)):
159159
ordered_rotations[i] = bwt_string[i] + ordered_rotations[i]
160160
ordered_rotations.sort()

0 commit comments

Comments
 (0)