Enable ruff ARG001 rule (#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>
This commit is contained in:
Maxim Smolskiy 2024-03-20 17:00:17 +03:00 committed by GitHub
parent 8faf823e83
commit a936e94704
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 22 additions and 31 deletions

View File

@ -22,12 +22,12 @@ of chosen elements is “tar”. For every element, we have two choices
"""
def combination_sum_iv(n: int, array: list[int], target: int) -> int:
def combination_sum_iv(array: list[int], target: int) -> int:
"""
Function checks the all possible combinations, and returns the count
of possible combination in exponential Time Complexity.
>>> combination_sum_iv(3, [1,2,5], 5)
>>> combination_sum_iv([1,2,5], 5)
9
"""
@ -41,13 +41,13 @@ def combination_sum_iv(n: int, array: list[int], target: int) -> int:
return count_of_possible_combinations(target)
def combination_sum_iv_dp_array(n: int, array: list[int], target: int) -> int:
def combination_sum_iv_dp_array(array: list[int], target: int) -> int:
"""
Function checks the all possible combinations, and returns the count
of possible combination in O(N^2) Time Complexity as we are using Dynamic
programming array here.
>>> combination_sum_iv_dp_array(3, [1,2,5], 5)
>>> combination_sum_iv_dp_array([1,2,5], 5)
9
"""
@ -96,7 +96,6 @@ if __name__ == "__main__":
import doctest
doctest.testmod()
n = 3
target = 5
array = [1, 2, 5]
print(combination_sum_iv(n, array, target))
print(combination_sum_iv(array, target))

View File

@ -240,7 +240,7 @@ def ascend_tree(leaf_node: TreeNode, prefix_path: list[str]) -> None:
ascend_tree(leaf_node.parent, prefix_path)
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict: # noqa: ARG001
"""
Find the conditional pattern base for a given base pattern.
@ -277,7 +277,7 @@ def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
def mine_tree(
in_tree: TreeNode,
in_tree: TreeNode, # noqa: ARG001
header_table: dict,
min_sup: int,
pre_fix: set,

View File

@ -227,7 +227,8 @@ def find_pure_symbols(
def find_unit_clauses(
clauses: list[Clause], model: dict[str, bool | None]
clauses: list[Clause],
model: dict[str, bool | None], # noqa: ARG001
) -> tuple[list[str], dict[str, bool | None]]:
"""
Returns the unit symbols and their values to satisfy clause.

View File

@ -51,18 +51,6 @@ def random(chars_incl: str, i: int) -> str:
return "".join(secrets.choice(chars_incl) for _ in range(i))
def random_number(chars_incl, i):
pass # Put your code here...
def random_letters(chars_incl, i):
pass # Put your code here...
def random_characters(chars_incl, i):
pass # Put your code here...
def is_strong_password(password: str, min_length: int = 8) -> bool:
"""
This will check whether a given password is strong or not. The password must be at

View File

@ -239,7 +239,7 @@ def plot(
ax.add_patch(patch)
# Function called at each step of the animation
def update(frame: int) -> list[plt.Circle]:
def update(frame: int) -> list[plt.Circle]: # noqa: ARG001
update_step(body_system, DELTA_TIME, patches)
return patches

View File

@ -110,7 +110,7 @@ def reversible_numbers(
if (length - 1) % 4 == 0:
return 0
return slow_reversible_numbers(length, 0, [0] * length, length)
return slow_reversible_numbers(remaining_length, remainder, digits, length)
def solution(max_power: int = 9) -> int:

View File

@ -26,6 +26,8 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
Return the sum of N(n) for 1 <= n <= n_limit.
>>> solution(1000,5)
222
>>> solution(1000,10)
249
>>> solution(10000,10)
2383
@ -45,7 +47,7 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
for hole_width in range(hole_width_lower_bound, outer_width - 1, 2):
count[outer_width * outer_width - hole_width * hole_width] += 1
return sum(1 for n in count.values() if 1 <= n <= 10)
return sum(1 for n in count.values() if 1 <= n <= n_limit)
if __name__ == "__main__":

View File

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

View File

@ -75,7 +75,10 @@ def calculate_turn_around_time(
def calculate_waiting_time(
process_name: list, turn_around_time: list, burst_time: list, no_of_process: int
process_name: list, # noqa: ARG001
turn_around_time: list,
burst_time: list,
no_of_process: int,
) -> list:
"""
Calculate the waiting time of each processes.

View File

@ -1,9 +1,8 @@
def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list:
def job_sequencing_with_deadlines(jobs: list) -> list:
"""
Function to find the maximum profit by doing jobs in a given time frame
Args:
num_jobs [int]: Number of jobs
jobs [list]: A list of tuples of (job_id, deadline, profit)
Returns:
@ -11,10 +10,10 @@ def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list:
in a given time frame
Examples:
>>> job_sequencing_with_deadlines(4,
>>> job_sequencing_with_deadlines(
... [(1, 4, 20), (2, 1, 10), (3, 1, 40), (4, 1, 30)])
[2, 60]
>>> job_sequencing_with_deadlines(5,
>>> job_sequencing_with_deadlines(
... [(1, 2, 100), (2, 1, 19), (3, 2, 27), (4, 1, 25), (5, 1, 15)])
[2, 127]
"""

View File

@ -3,7 +3,7 @@ import shutil
import requests
def get_apod_data(api_key: str, download: bool = False, path: str = ".") -> dict:
def get_apod_data(api_key: str) -> dict:
"""
Get the APOD(Astronomical Picture of the day) data
Get your API Key from: https://api.nasa.gov/