Enable ruff RUF100 rule (#11337)

This commit is contained in:
Maxim Smolskiy 2024-04-01 22:36:41 +03:00 committed by GitHub
parent c328b000ec
commit 39daaf8248
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 23 additions and 24 deletions

View File

@ -13,7 +13,7 @@ Alternatively you can use scipy.signal.butter, which should yield the same resul
def make_lowpass(
frequency: int,
samplerate: int,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a low-pass filter
@ -43,7 +43,7 @@ def make_lowpass(
def make_highpass(
frequency: int,
samplerate: int,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a high-pass filter
@ -73,7 +73,7 @@ def make_highpass(
def make_bandpass(
frequency: int,
samplerate: int,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a band-pass filter
@ -104,7 +104,7 @@ def make_bandpass(
def make_allpass(
frequency: int,
samplerate: int,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates an all-pass filter
@ -132,7 +132,7 @@ def make_peak(
frequency: int,
samplerate: int,
gain_db: float,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a peak filter
@ -164,7 +164,7 @@ def make_lowshelf(
frequency: int,
samplerate: int,
gain_db: float,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a low-shelf filter
@ -201,7 +201,7 @@ def make_highshelf(
frequency: int,
samplerate: int,
gain_db: float,
q_factor: float = 1 / sqrt(2), # noqa: B008
q_factor: float = 1 / sqrt(2),
) -> IIRFilter:
"""
Creates a high-shelf filter

View File

@ -85,7 +85,7 @@ class BinaryTree:
"""
return self._depth(self.root)
def _depth(self, node: Node | None) -> int: # noqa: UP007
def _depth(self, node: Node | None) -> int:
if not node:
return 0
return 1 + max(self._depth(node.left), self._depth(node.right))

View File

@ -87,7 +87,7 @@ class SegmentTree(Generic[T]):
p = p // 2
self.st[p] = self.fn(self.st[p * 2], self.st[p * 2 + 1])
def query(self, l: int, r: int) -> T | None: # noqa: E741
def query(self, l: int, r: int) -> T | None:
"""
Get range query value in log(N) time
:param l: left element index

View File

@ -152,7 +152,7 @@ class RedBlackTree:
self.grandparent.color = 1
self.grandparent._insert_repair()
def remove(self, label: int) -> RedBlackTree: # noqa: PLR0912
def remove(self, label: int) -> RedBlackTree:
"""Remove label from this tree."""
if self.label == label:
if self.left and self.right:

View File

@ -35,7 +35,7 @@ class SegmentTree:
"""
return idx * 2 + 1
def build(self, idx, l, r): # noqa: E741
def build(self, idx, l, r):
if l == r:
self.st[idx] = self.A[l]
else:
@ -56,7 +56,7 @@ class SegmentTree:
"""
return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)
def update_recursive(self, idx, l, r, a, b, val): # noqa: E741
def update_recursive(self, idx, l, r, a, b, val):
"""
update(1, 1, N, a, b, v) for update val v to [a,b]
"""
@ -83,7 +83,7 @@ class SegmentTree:
"""
return self.query_recursive(1, 0, self.N - 1, a - 1, b - 1)
def query_recursive(self, idx, l, r, a, b): # noqa: E741
def query_recursive(self, idx, l, r, a, b):
"""
query(1, 1, N, a, b) for query max of [a,b]
"""

View File

@ -66,7 +66,7 @@ class MinHeap:
# this is min-heapify method
def sift_down(self, idx, array):
while True:
l = self.get_left_child_idx(idx) # noqa: E741
l = self.get_left_child_idx(idx)
r = self.get_right_child_idx(idx)
smallest = idx

View File

@ -38,7 +38,7 @@ def longest_common_subsequence(x: str, y: str):
n = len(y)
# declaring the array for storing the dp values
l = [[0] * (n + 1) for _ in range(m + 1)] # noqa: E741
l = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(1, m + 1):
for j in range(1, n + 1):

View File

@ -7,13 +7,13 @@
from __future__ import annotations
def ceil_index(v, l, r, key): # noqa: E741
def ceil_index(v, l, r, key):
while r - l > 1:
m = (l + r) // 2
if v[m] >= key:
r = m
else:
l = m # noqa: E741
l = m
return r

View File

@ -1,5 +1,5 @@
# Finding Articulation Points in Undirected Graph
def compute_ap(l): # noqa: E741
def compute_ap(l):
n = len(l)
out_edge_count = 0
low = [0] * n

View File

@ -37,7 +37,7 @@ class Dinic:
# Here we calculate the flow that reaches the sink
def max_flow(self, source, sink):
flow, self.q[0] = 0, source
for l in range(31): # noqa: E741 l = 30 maybe faster for random data
for l in range(31): # l = 30 maybe faster for random data
while True:
self.lvl, self.ptr = [0] * len(self.q), [0] * len(self.q)
qi, qe, self.lvl[source] = 0, 1, 1

View File

@ -44,9 +44,9 @@ def function(expansion, s0, s1, key, message):
right = message[4:]
temp = apply_table(right, expansion)
temp = xor(temp, key)
l = apply_sbox(s0, temp[:4]) # noqa: E741
l = apply_sbox(s0, temp[:4])
r = apply_sbox(s1, temp[4:])
l = "0" * (2 - len(l)) + l # noqa: E741
l = "0" * (2 - len(l)) + l
r = "0" * (2 - len(r)) + r
temp = apply_table(l + r, p4_table)
temp = xor(left, temp)

View File

@ -35,7 +35,7 @@ def solution():
70600674
"""
with open(os.path.dirname(__file__) + "/grid.txt") as f:
l = [] # noqa: E741
l = []
for _ in range(20):
l.append([int(x) for x in f.readline().split()])

View File

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

View File

@ -50,7 +50,7 @@ def palindromic_string(input_string: str) -> str:
# does this string is ending after the previously explored end (that is r) ?
# if yes the update the new r to the last index of this
if j + k - 1 > r:
l = j - k + 1 # noqa: E741
l = j - k + 1
r = j + k - 1
# update max_length and start position