Skip to content

Commit 39daaf8

Browse files
Enable ruff RUF100 rule (#11337)
1 parent c328b00 commit 39daaf8

14 files changed

+23
-24
lines changed

audio_filters/butterworth_filter.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def make_lowpass(
1414
frequency: int,
1515
samplerate: int,
16-
q_factor: float = 1 / sqrt(2), # noqa: B008
16+
q_factor: float = 1 / sqrt(2),
1717
) -> IIRFilter:
1818
"""
1919
Creates a low-pass filter
@@ -43,7 +43,7 @@ def make_lowpass(
4343
def make_highpass(
4444
frequency: int,
4545
samplerate: int,
46-
q_factor: float = 1 / sqrt(2), # noqa: B008
46+
q_factor: float = 1 / sqrt(2),
4747
) -> IIRFilter:
4848
"""
4949
Creates a high-pass filter
@@ -73,7 +73,7 @@ def make_highpass(
7373
def make_bandpass(
7474
frequency: int,
7575
samplerate: int,
76-
q_factor: float = 1 / sqrt(2), # noqa: B008
76+
q_factor: float = 1 / sqrt(2),
7777
) -> IIRFilter:
7878
"""
7979
Creates a band-pass filter
@@ -104,7 +104,7 @@ def make_bandpass(
104104
def make_allpass(
105105
frequency: int,
106106
samplerate: int,
107-
q_factor: float = 1 / sqrt(2), # noqa: B008
107+
q_factor: float = 1 / sqrt(2),
108108
) -> IIRFilter:
109109
"""
110110
Creates an all-pass filter
@@ -132,7 +132,7 @@ def make_peak(
132132
frequency: int,
133133
samplerate: int,
134134
gain_db: float,
135-
q_factor: float = 1 / sqrt(2), # noqa: B008
135+
q_factor: float = 1 / sqrt(2),
136136
) -> IIRFilter:
137137
"""
138138
Creates a peak filter
@@ -164,7 +164,7 @@ def make_lowshelf(
164164
frequency: int,
165165
samplerate: int,
166166
gain_db: float,
167-
q_factor: float = 1 / sqrt(2), # noqa: B008
167+
q_factor: float = 1 / sqrt(2),
168168
) -> IIRFilter:
169169
"""
170170
Creates a low-shelf filter
@@ -201,7 +201,7 @@ def make_highshelf(
201201
frequency: int,
202202
samplerate: int,
203203
gain_db: float,
204-
q_factor: float = 1 / sqrt(2), # noqa: B008
204+
q_factor: float = 1 / sqrt(2),
205205
) -> IIRFilter:
206206
"""
207207
Creates a high-shelf filter

data_structures/binary_tree/basic_binary_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def depth(self) -> int:
8585
"""
8686
return self._depth(self.root)
8787

88-
def _depth(self, node: Node | None) -> int: # noqa: UP007
88+
def _depth(self, node: Node | None) -> int:
8989
if not node:
9090
return 0
9191
return 1 + max(self._depth(node.left), self._depth(node.right))

data_structures/binary_tree/non_recursive_segment_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def update(self, p: int, v: T) -> None:
8787
p = p // 2
8888
self.st[p] = self.fn(self.st[p * 2], self.st[p * 2 + 1])
8989

90-
def query(self, l: int, r: int) -> T | None: # noqa: E741
90+
def query(self, l: int, r: int) -> T | None:
9191
"""
9292
Get range query value in log(N) time
9393
:param l: left element index

data_structures/binary_tree/red_black_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _insert_repair(self) -> None:
152152
self.grandparent.color = 1
153153
self.grandparent._insert_repair()
154154

155-
def remove(self, label: int) -> RedBlackTree: # noqa: PLR0912
155+
def remove(self, label: int) -> RedBlackTree:
156156
"""Remove label from this tree."""
157157
if self.label == label:
158158
if self.left and self.right:

data_structures/binary_tree/segment_tree.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def right(self, idx):
3535
"""
3636
return idx * 2 + 1
3737

38-
def build(self, idx, l, r): # noqa: E741
38+
def build(self, idx, l, r):
3939
if l == r:
4040
self.st[idx] = self.A[l]
4141
else:
@@ -56,7 +56,7 @@ def update(self, a, b, val):
5656
"""
5757
return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)
5858

59-
def update_recursive(self, idx, l, r, a, b, val): # noqa: E741
59+
def update_recursive(self, idx, l, r, a, b, val):
6060
"""
6161
update(1, 1, N, a, b, v) for update val v to [a,b]
6262
"""
@@ -83,7 +83,7 @@ def query(self, a, b):
8383
"""
8484
return self.query_recursive(1, 0, self.N - 1, a - 1, b - 1)
8585

86-
def query_recursive(self, idx, l, r, a, b): # noqa: E741
86+
def query_recursive(self, idx, l, r, a, b):
8787
"""
8888
query(1, 1, N, a, b) for query max of [a,b]
8989
"""

data_structures/heap/min_heap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def build_heap(self, array):
6666
# this is min-heapify method
6767
def sift_down(self, idx, array):
6868
while True:
69-
l = self.get_left_child_idx(idx) # noqa: E741
69+
l = self.get_left_child_idx(idx)
7070
r = self.get_right_child_idx(idx)
7171

7272
smallest = idx

dynamic_programming/longest_common_subsequence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def longest_common_subsequence(x: str, y: str):
3838
n = len(y)
3939

4040
# declaring the array for storing the dp values
41-
l = [[0] * (n + 1) for _ in range(m + 1)] # noqa: E741
41+
l = [[0] * (n + 1) for _ in range(m + 1)]
4242

4343
for i in range(1, m + 1):
4444
for j in range(1, n + 1):

dynamic_programming/longest_increasing_subsequence_o_nlogn.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
from __future__ import annotations
88

99

10-
def ceil_index(v, l, r, key): # noqa: E741
10+
def ceil_index(v, l, r, key):
1111
while r - l > 1:
1212
m = (l + r) // 2
1313
if v[m] >= key:
1414
r = m
1515
else:
16-
l = m # noqa: E741
16+
l = m
1717
return r
1818

1919

graphs/articulation_points.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Finding Articulation Points in Undirected Graph
2-
def compute_ap(l): # noqa: E741
2+
def compute_ap(l):
33
n = len(l)
44
out_edge_count = 0
55
low = [0] * n

graphs/dinic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def depth_first_search(self, vertex, sink, flow):
3737
# Here we calculate the flow that reaches the sink
3838
def max_flow(self, source, sink):
3939
flow, self.q[0] = 0, source
40-
for l in range(31): # noqa: E741 l = 30 maybe faster for random data
40+
for l in range(31): # l = 30 maybe faster for random data
4141
while True:
4242
self.lvl, self.ptr = [0] * len(self.q), [0] * len(self.q)
4343
qi, qe, self.lvl[source] = 0, 1, 1

other/sdes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def function(expansion, s0, s1, key, message):
4444
right = message[4:]
4545
temp = apply_table(right, expansion)
4646
temp = xor(temp, key)
47-
l = apply_sbox(s0, temp[:4]) # noqa: E741
47+
l = apply_sbox(s0, temp[:4])
4848
r = apply_sbox(s1, temp[4:])
49-
l = "0" * (2 - len(l)) + l # noqa: E741
49+
l = "0" * (2 - len(l)) + l
5050
r = "0" * (2 - len(r)) + r
5151
temp = apply_table(l + r, p4_table)
5252
temp = xor(left, temp)

project_euler/problem_011/sol2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def solution():
3535
70600674
3636
"""
3737
with open(os.path.dirname(__file__) + "/grid.txt") as f:
38-
l = [] # noqa: E741
38+
l = []
3939
for _ in range(20):
4040
l.append([int(x) for x in f.readline().split()])
4141

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
1515
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
1616
"PT018", # Assertion should be broken down into multiple parts
1717
"RUF00", # Ambiguous unicode character and other rules
18-
"RUF100", # Unused `noqa` directive -- FIX ME
1918
"S101", # Use of `assert` detected -- DO NOT FIX
2019
"S105", # Possible hardcoded password: 'password'
2120
"S113", # Probable use of requests call without timeout -- FIX ME

strings/manacher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def palindromic_string(input_string: str) -> str:
5050
# does this string is ending after the previously explored end (that is r) ?
5151
# if yes the update the new r to the last index of this
5252
if j + k - 1 > r:
53-
l = j - k + 1 # noqa: E741
53+
l = j - k + 1
5454
r = j + k - 1
5555

5656
# update max_length and start position

0 commit comments

Comments
 (0)