Skip to content

Commit

Permalink
Enable ruff ARG001 rule (#11321)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
MaximSmolskiy and pre-commit-ci[bot] authored Mar 20, 2024
1 parent 8faf823 commit a936e94
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 31 deletions.
11 changes: 5 additions & 6 deletions dynamic_programming/combination_sum_iv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"""


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
"""

Expand All @@ -41,13 +41,13 @@ def count_of_possible_combinations(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
"""

Expand Down Expand Up @@ -96,7 +96,6 @@ def combination_sum_iv_bottom_up(n: int, array: list[int], target: int) -> int:
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))
4 changes: 2 additions & 2 deletions machine_learning/frequent_pattern_growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion other/davis_putnam_logemann_loveland.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions other/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion physics/n_body_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion project_euler/problem_145/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion project_euler/problem_174/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__":
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion scheduling/highest_response_ratio_next.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions scheduling/job_sequencing_with_deadline.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
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:
max_profit [int]: Maximum profit that can be earned by doing jobs
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]
"""
Expand Down
2 changes: 1 addition & 1 deletion web_programming/nasa_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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/
Expand Down

0 comments on commit a936e94

Please sign in to comment.