Skip to content

Commit a936e94

Browse files
Enable ruff ARG001 rule (TheAlgorithms#11321)
* Enable ruff ARG001 rule * Fix dynamic_programming/combination_sum_iv.py * Fix machine_learning/frequent_pattern_growth.py * Fix other/davis_putnam_logemann_loveland.py * Fix other/password.py * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix physics/n_body_simulation.py * Fix project_euler/problem_145/sol1.py * Fix project_euler/problem_174/sol1.py * Fix scheduling/highest_response_ratio_next.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Fix * Fix scheduling/job_sequencing_with_deadline.py * Fix scheduling/job_sequencing_with_deadline.py * Fix * Fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8faf823 commit a936e94

File tree

11 files changed

+22
-31
lines changed

11 files changed

+22
-31
lines changed

dynamic_programming/combination_sum_iv.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
"""
2323

2424

25-
def combination_sum_iv(n: int, array: list[int], target: int) -> int:
25+
def combination_sum_iv(array: list[int], target: int) -> int:
2626
"""
2727
Function checks the all possible combinations, and returns the count
2828
of possible combination in exponential Time Complexity.
2929
30-
>>> combination_sum_iv(3, [1,2,5], 5)
30+
>>> combination_sum_iv([1,2,5], 5)
3131
9
3232
"""
3333

@@ -41,13 +41,13 @@ def count_of_possible_combinations(target: int) -> int:
4141
return count_of_possible_combinations(target)
4242

4343

44-
def combination_sum_iv_dp_array(n: int, array: list[int], target: int) -> int:
44+
def combination_sum_iv_dp_array(array: list[int], target: int) -> int:
4545
"""
4646
Function checks the all possible combinations, and returns the count
4747
of possible combination in O(N^2) Time Complexity as we are using Dynamic
4848
programming array here.
4949
50-
>>> combination_sum_iv_dp_array(3, [1,2,5], 5)
50+
>>> combination_sum_iv_dp_array([1,2,5], 5)
5151
9
5252
"""
5353

@@ -96,7 +96,6 @@ def combination_sum_iv_bottom_up(n: int, array: list[int], target: int) -> int:
9696
import doctest
9797

9898
doctest.testmod()
99-
n = 3
10099
target = 5
101100
array = [1, 2, 5]
102-
print(combination_sum_iv(n, array, target))
101+
print(combination_sum_iv(array, target))

machine_learning/frequent_pattern_growth.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def ascend_tree(leaf_node: TreeNode, prefix_path: list[str]) -> None:
240240
ascend_tree(leaf_node.parent, prefix_path)
241241

242242

243-
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
243+
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict: # noqa: ARG001
244244
"""
245245
Find the conditional pattern base for a given base pattern.
246246
@@ -277,7 +277,7 @@ def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
277277

278278

279279
def mine_tree(
280-
in_tree: TreeNode,
280+
in_tree: TreeNode, # noqa: ARG001
281281
header_table: dict,
282282
min_sup: int,
283283
pre_fix: set,

other/davis_putnam_logemann_loveland.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def find_pure_symbols(
227227

228228

229229
def find_unit_clauses(
230-
clauses: list[Clause], model: dict[str, bool | None]
230+
clauses: list[Clause],
231+
model: dict[str, bool | None], # noqa: ARG001
231232
) -> tuple[list[str], dict[str, bool | None]]:
232233
"""
233234
Returns the unit symbols and their values to satisfy clause.

other/password.py

-12
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ def random(chars_incl: str, i: int) -> str:
5151
return "".join(secrets.choice(chars_incl) for _ in range(i))
5252

5353

54-
def random_number(chars_incl, i):
55-
pass # Put your code here...
56-
57-
58-
def random_letters(chars_incl, i):
59-
pass # Put your code here...
60-
61-
62-
def random_characters(chars_incl, i):
63-
pass # Put your code here...
64-
65-
6654
def is_strong_password(password: str, min_length: int = 8) -> bool:
6755
"""
6856
This will check whether a given password is strong or not. The password must be at

physics/n_body_simulation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def plot(
239239
ax.add_patch(patch)
240240

241241
# Function called at each step of the animation
242-
def update(frame: int) -> list[plt.Circle]:
242+
def update(frame: int) -> list[plt.Circle]: # noqa: ARG001
243243
update_step(body_system, DELTA_TIME, patches)
244244
return patches
245245

project_euler/problem_145/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def reversible_numbers(
110110
if (length - 1) % 4 == 0:
111111
return 0
112112

113-
return slow_reversible_numbers(length, 0, [0] * length, length)
113+
return slow_reversible_numbers(remaining_length, remainder, digits, length)
114114

115115

116116
def solution(max_power: int = 9) -> int:

project_euler/problem_174/sol1.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
2626
Return the sum of N(n) for 1 <= n <= n_limit.
2727
2828
>>> solution(1000,5)
29+
222
30+
>>> solution(1000,10)
2931
249
3032
>>> solution(10000,10)
3133
2383
@@ -45,7 +47,7 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
4547
for hole_width in range(hole_width_lower_bound, outer_width - 1, 2):
4648
count[outer_width * outer_width - hole_width * hole_width] += 1
4749

48-
return sum(1 for n in count.values() if 1 <= n <= 10)
50+
return sum(1 for n in count.values() if 1 <= n <= n_limit)
4951

5052

5153
if __name__ == "__main__":

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[tool.ruff]
22
lint.ignore = [ # `ruff rule S101` for a description of that rule
3-
"ARG001", # Unused function argument `amount` -- FIX ME?
43
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
54
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
65
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed -- FIX ME

scheduling/highest_response_ratio_next.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def calculate_turn_around_time(
7575

7676

7777
def calculate_waiting_time(
78-
process_name: list, turn_around_time: list, burst_time: list, no_of_process: int
78+
process_name: list, # noqa: ARG001
79+
turn_around_time: list,
80+
burst_time: list,
81+
no_of_process: int,
7982
) -> list:
8083
"""
8184
Calculate the waiting time of each processes.

scheduling/job_sequencing_with_deadline.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list:
1+
def job_sequencing_with_deadlines(jobs: list) -> list:
22
"""
33
Function to find the maximum profit by doing jobs in a given time frame
44
55
Args:
6-
num_jobs [int]: Number of jobs
76
jobs [list]: A list of tuples of (job_id, deadline, profit)
87
98
Returns:
109
max_profit [int]: Maximum profit that can be earned by doing jobs
1110
in a given time frame
1211
1312
Examples:
14-
>>> job_sequencing_with_deadlines(4,
13+
>>> job_sequencing_with_deadlines(
1514
... [(1, 4, 20), (2, 1, 10), (3, 1, 40), (4, 1, 30)])
1615
[2, 60]
17-
>>> job_sequencing_with_deadlines(5,
16+
>>> job_sequencing_with_deadlines(
1817
... [(1, 2, 100), (2, 1, 19), (3, 2, 27), (4, 1, 25), (5, 1, 15)])
1918
[2, 127]
2019
"""

web_programming/nasa_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import requests
44

55

6-
def get_apod_data(api_key: str, download: bool = False, path: str = ".") -> dict:
6+
def get_apod_data(api_key: str) -> dict:
77
"""
88
Get the APOD(Astronomical Picture of the day) data
99
Get your API Key from: https://api.nasa.gov/

0 commit comments

Comments
 (0)