Skip to content

Commit 6f21f76

Browse files
authored
fix(ci): Update pre-commit hooks and apply new black (TheAlgorithms#4359)
* fix(ci): Update pre-commit hooks and apply new black * remove empty docstring
1 parent 6945735 commit 6f21f76

File tree

13 files changed

+26
-27
lines changed

13 files changed

+26
-27
lines changed

Diff for: .github/workflows/pre-commit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
~/.cache/pip
1515
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
1616
- uses: actions/setup-python@v2
17-
- uses: psf/black@20.8b1
17+
- uses: psf/black@21.4b0
1818
- name: Install pre-commit
1919
run: |
2020
python -m pip install --upgrade pip

Diff for: .pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ repos:
1313
)$
1414
- id: requirements-txt-fixer
1515
- repo: https://github.com/psf/black
16-
rev: 20.8b1
16+
rev: 21.4b0
1717
hooks:
1818
- id: black
1919
- repo: https://github.com/PyCQA/isort
20-
rev: 5.7.0
20+
rev: 5.8.0
2121
hooks:
2222
- id: isort
2323
args:
2424
- --profile=black
2525
- repo: https://gitlab.com/pycqa/flake8
26-
rev: 3.9.0
26+
rev: 3.9.1
2727
hooks:
2828
- id: flake8
2929
args:

Diff for: data_structures/binary_tree/binary_search_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def inorder(self, arr: list, node: Node):
150150
self.inorder(arr, node.right)
151151

152152
def find_kth_smallest(self, k: int, node: Node) -> int:
153-
"""Return the kth smallest element in a binary search tree """
153+
"""Return the kth smallest element in a binary search tree"""
154154
arr = []
155155
self.inorder(arr, node) # append all values to list using inorder traversal
156156
return arr[k - 1]

Diff for: data_structures/heap/heap.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __repr__(self) -> str:
3232
return str(self.h)
3333

3434
def parent_index(self, child_idx: int) -> Optional[int]:
35-
""" return the parent index of given child """
35+
"""return the parent index of given child"""
3636
if child_idx > 0:
3737
return (child_idx - 1) // 2
3838
return None
@@ -78,7 +78,7 @@ def max_heapify(self, index: int) -> None:
7878
self.max_heapify(violation)
7979

8080
def build_max_heap(self, collection: Iterable[float]) -> None:
81-
""" build max heap from an unsorted array"""
81+
"""build max heap from an unsorted array"""
8282
self.h = list(collection)
8383
self.heap_size = len(self.h)
8484
if self.heap_size > 1:
@@ -87,14 +87,14 @@ def build_max_heap(self, collection: Iterable[float]) -> None:
8787
self.max_heapify(i)
8888

8989
def max(self) -> float:
90-
""" return the max in the heap """
90+
"""return the max in the heap"""
9191
if self.heap_size >= 1:
9292
return self.h[0]
9393
else:
9494
raise Exception("Empty heap")
9595

9696
def extract_max(self) -> float:
97-
""" get and remove max from heap """
97+
"""get and remove max from heap"""
9898
if self.heap_size >= 2:
9999
me = self.h[0]
100100
self.h[0] = self.h.pop(-1)
@@ -108,7 +108,7 @@ def extract_max(self) -> float:
108108
raise Exception("Empty heap")
109109

110110
def insert(self, value: float) -> None:
111-
""" insert a new value into the max heap """
111+
"""insert a new value into the max heap"""
112112
self.h.append(value)
113113
idx = (self.heap_size - 1) // 2
114114
self.heap_size += 1

Diff for: data_structures/heap/max_heap.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self):
2121
self.__size = 0
2222

2323
def __swap_up(self, i: int) -> None:
24-
""" Swap the element up """
24+
"""Swap the element up"""
2525
temporary = self.__heap[i]
2626
while i // 2 > 0:
2727
if self.__heap[i] > self.__heap[i // 2]:
@@ -30,13 +30,13 @@ def __swap_up(self, i: int) -> None:
3030
i //= 2
3131

3232
def insert(self, value: int) -> None:
33-
""" Insert new element """
33+
"""Insert new element"""
3434
self.__heap.append(value)
3535
self.__size += 1
3636
self.__swap_up(self.__size)
3737

3838
def __swap_down(self, i: int) -> None:
39-
""" Swap the element down """
39+
"""Swap the element down"""
4040
while self.__size >= 2 * i:
4141
if 2 * i + 1 > self.__size:
4242
bigger_child = 2 * i
@@ -52,7 +52,7 @@ def __swap_down(self, i: int) -> None:
5252
i = bigger_child
5353

5454
def pop(self) -> int:
55-
""" Pop the root element """
55+
"""Pop the root element"""
5656
max_value = self.__heap[1]
5757
self.__heap[1] = self.__heap[self.__size]
5858
self.__size -= 1
@@ -65,7 +65,7 @@ def get_list(self):
6565
return self.__heap[1:]
6666

6767
def __len__(self):
68-
""" Length of the array """
68+
"""Length of the array"""
6969
return self.__size
7070

7171

Diff for: data_structures/linked_list/deque_doubly.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class _DoublyLinkedBase:
12-
""" A Private class (to be inherited) """
12+
"""A Private class (to be inherited)"""
1313

1414
class _Node:
1515
__slots__ = "_prev", "_data", "_next"

Diff for: data_structures/stacks/stack.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ def __str__(self) -> str:
2222
return str(self.stack)
2323

2424
def push(self, data):
25-
""" Push an element to the top of the stack."""
25+
"""Push an element to the top of the stack."""
2626
if len(self.stack) >= self.limit:
2727
raise StackOverflowError
2828
self.stack.append(data)
2929

3030
def pop(self):
31-
""" Pop an element off of the top of the stack."""
31+
"""Pop an element off of the top of the stack."""
3232
return self.stack.pop()
3333

3434
def peek(self):
35-
""" Peek at the top-most element of the stack."""
35+
"""Peek at the top-most element of the stack."""
3636
return self.stack[-1]
3737

3838
def is_empty(self) -> bool:
39-
""" Check if a stack is empty."""
39+
"""Check if a stack is empty."""
4040
return not bool(self.stack)
4141

4242
def is_full(self) -> bool:
4343
return self.size() == self.limit
4444

4545
def size(self) -> int:
46-
""" Return the size of the stack."""
46+
"""Return the size of the stack."""
4747
return len(self.stack)
4848

4949
def __contains__(self, item) -> bool:

Diff for: digital_image_processing/sepia.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def to_grayscale(blue, green, red):
1919
return 0.2126 * red + 0.587 * green + 0.114 * blue
2020

2121
def normalize(value):
22-
""" Helper function to normalize R/G/B value -> return 255 if value > 255"""
22+
"""Helper function to normalize R/G/B value -> return 255 if value > 255"""
2323
return min(value, 255)
2424

2525
for i in range(pixel_h):

Diff for: hashes/md5.py

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def not32(i):
9494

9595

9696
def sum32(a, b):
97-
""""""
9897
return (a + b) % 2 ** 32
9998

10099

Diff for: machine_learning/linear_discriminant_analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def valid_input(
283283

284284
# Main Function
285285
def main():
286-
""" This function starts execution phase """
286+
"""This function starts execution phase"""
287287
while True:
288288
print(" Linear Discriminant Analysis ".center(50, "*"))
289289
print("*" * 50, "\n")

Diff for: machine_learning/linear_regression.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def run_linear_regression(data_x, data_y):
8888

8989

9090
def main():
91-
""" Driver function """
91+
"""Driver function"""
9292
data = collect_dataset()
9393

9494
len_data = data.shape[0]

Diff for: maths/monte_carlo_dice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Dice:
77
NUM_SIDES = 6
88

99
def __init__(self):
10-
""" Initialize a six sided dice """
10+
"""Initialize a six sided dice"""
1111
self.sides = list(range(1, Dice.NUM_SIDES + 1))
1212

1313
def roll(self):

Diff for: other/least_recently_used.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class LRUCache:
7-
""" Page Replacement Algorithm, Least Recently Used (LRU) Caching."""
7+
"""Page Replacement Algorithm, Least Recently Used (LRU) Caching."""
88

99
dq_store = object() # Cache store of keys
1010
key_reference_map = object() # References of the keys in cache

0 commit comments

Comments
 (0)