Skip to content

Commit

Permalink
pre-commit: Upgrade psf/black for stable style 2023 (TheAlgorithms#8110)
Browse files Browse the repository at this point in the history
* pre-commit: Upgrade psf/black for stable style 2023

Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310

> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…

Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.

I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cclauss and pre-commit-ci[bot] authored Feb 1, 2023
1 parent ed0a581 commit c909da9
Show file tree
Hide file tree
Showing 97 changed files with 19 additions and 154 deletions.
12 changes: 11 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: auto-walrus

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black

Expand All @@ -26,6 +26,16 @@ repos:
args:
- --profile=black

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.6.0"
hooks:
- id: pyproject-fmt

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: validate-pyproject

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
Expand Down
1 change: 0 additions & 1 deletion arithmetic_analysis/newton_raphson_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def newton_raphson(

# Let's Execute
if __name__ == "__main__":

# Find root of trigonometric function
# Find value of pi
print(f"The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}")
Expand Down
1 change: 0 additions & 1 deletion backtracking/n_queens_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def depth_first_search(

# We iterate each column in the row to find all possible results in each row
for col in range(n):

# We apply that we learned previously. First we check that in the current board
# (possible_board) there are not other same value because if there is it means
# that there are a collision in vertical. Then we apply the two formulas we
Expand Down
1 change: 1 addition & 0 deletions blockchain/chinese_remainder_theorem.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def chinese_remainder_theorem(n1: int, r1: int, n2: int, r2: int) -> int:

# ----------SAME SOLUTION USING InvertModulo instead ExtendedEuclid----------------


# This function find the inverses of a i.e., a^(-1)
def invert_modulo(a: int, n: int) -> int:
"""
Expand Down
1 change: 0 additions & 1 deletion ciphers/enigma_machine2.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def enigma(
# encryption/decryption process --------------------------
for symbol in text:
if symbol in abc:

# 1st plugboard --------------------------
if symbol in plugboard:
symbol = plugboard[symbol]
Expand Down
1 change: 0 additions & 1 deletion ciphers/playfair_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def prepare_input(dirty: str) -> str:


def generate_table(key: str) -> list[str]:

# I and J are used interchangeably to allow
# us to use a 5x5 table (25 letters)
alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
Expand Down
1 change: 0 additions & 1 deletion ciphers/polybius.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

class PolybiusCipher:
def __init__(self) -> None:

self.SQUARE = np.array(SQUARE)

def letter_to_numbers(self, letter: str) -> np.ndarray:
Expand Down
2 changes: 0 additions & 2 deletions ciphers/xor_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def encrypt_file(self, file: str, key: int = 0) -> bool:
try:
with open(file) as fin:
with open("encrypt.out", "w+") as fout:

# actual encrypt-process
for line in fin:
fout.write(self.encrypt_string(line, key))
Expand All @@ -155,7 +154,6 @@ def decrypt_file(self, file: str, key: int) -> bool:
try:
with open(file) as fin:
with open("decrypt.out", "w+") as fout:

# actual encrypt-process
for line in fin:
fout.write(self.decrypt_string(line, key))
Expand Down
1 change: 0 additions & 1 deletion compression/lz77.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def compress(self, text: str) -> list[Token]:

# while there are still characters in text to compress
while text:

# find the next encoding phrase
# - triplet with offset, length, indicator (the next encoding character)
token = self._find_encoding_token(text, search_buffer)
Expand Down
1 change: 0 additions & 1 deletion computer_vision/cnn_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from tensorflow.keras import layers, models

if __name__ == "__main__":

# Initialising the CNN
# (Sequential- Building the model layer by layer)
classifier = models.Sequential()
Expand Down
3 changes: 0 additions & 3 deletions computer_vision/harris_corner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class HarrisCorner:
def __init__(self, k: float, window_size: int):

"""
k : is an empirically determined constant in [0.04,0.06]
window_size : neighbourhoods considered
Expand All @@ -25,7 +24,6 @@ def __str__(self) -> str:
return str(self.k)

def detect(self, img_path: str) -> tuple[cv2.Mat, list[list[int]]]:

"""
Returns the image with corners identified
img_path : path of the image
Expand Down Expand Up @@ -68,7 +66,6 @@ def detect(self, img_path: str) -> tuple[cv2.Mat, list[list[int]]]:


if __name__ == "__main__":

edge_detect = HarrisCorner(0.04, 3)
color_img, _ = edge_detect.detect("path_to_image")
cv2.imwrite("detect.png", color_img)
1 change: 0 additions & 1 deletion conversions/decimal_to_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


def decimal_to_binary(num: int) -> str:

"""
Convert an Integer Decimal Number to a Binary Number as str.
>>> decimal_to_binary(0)
Expand Down
1 change: 0 additions & 1 deletion conversions/molecular_chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def pressure_and_volume_to_temperature(


if __name__ == "__main__":

import doctest

doctest.testmod()
2 changes: 1 addition & 1 deletion conversions/roman_numerals.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def int_to_roman(number: int) -> str:
True
"""
result = []
for (arabic, roman) in ROMAN:
for arabic, roman in ROMAN:
(factor, number) = divmod(number, arabic)
result.append(roman * factor)
if number == 0:
Expand Down
1 change: 0 additions & 1 deletion conversions/temperature_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def reaumur_to_rankine(reaumur: float, ndigits: int = 2) -> float:


if __name__ == "__main__":

import doctest

doctest.testmod()
1 change: 0 additions & 1 deletion conversions/weight_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ def weight_conversion(from_type: str, to_type: str, value: float) -> float:


if __name__ == "__main__":

import doctest

doctest.testmod()
1 change: 0 additions & 1 deletion data_structures/binary_tree/binary_tree_traversals.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def populate_output(root: Node | None, level: int) -> None:
if not root:
return
if level == 1:

output.append(root.data)
elif level > 1:
populate_output(root.left, level - 1)
Expand Down
1 change: 0 additions & 1 deletion data_structures/binary_tree/inorder_tree_traversal_2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def inorder(node: None | BinaryTreeNode) -> list[int]: # if node is None,return


def make_tree() -> BinaryTreeNode | None:

root = insert(None, 15)
insert(root, 10)
insert(root, 25)
Expand Down
1 change: 0 additions & 1 deletion data_structures/hashing/double_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def __hash_function_2(self, value, data):

next_prime_gt = (
next_prime(value % self.size_table)
if not is_prime(value % self.size_table)
Expand Down
2 changes: 0 additions & 2 deletions data_structures/hashing/hash_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def hash_function(self, key):
return key % self.size_table

def _step_by_step(self, step_ord):

print(f"step {step_ord}")
print(list(range(len(self.values))))
print(self.values)
Expand All @@ -53,7 +52,6 @@ def _collision_resolution(self, key, data=None):
new_key = self.hash_function(key + 1)

while self.values[new_key] is not None and self.values[new_key] != key:

if self.values.count(None) > 0:
new_key = self.hash_function(new_key + 1)
else:
Expand Down
2 changes: 0 additions & 2 deletions data_structures/heap/binomial_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def merge_heaps(self, other):
i.left_tree_size == i.parent.left_tree_size
and i.left_tree_size != i.parent.parent.left_tree_size
):

# Neighbouring Nodes
previous_node = i.left
next_node = i.parent.parent
Expand Down Expand Up @@ -233,7 +232,6 @@ def insert(self, val):
and self.bottom_root.left_tree_size
== self.bottom_root.parent.left_tree_size
):

# Next node
next_node = self.bottom_root.parent.parent

Expand Down
1 change: 0 additions & 1 deletion data_structures/heap/skew_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class SkewHeap(Generic[T]):
"""

def __init__(self, data: Iterable[T] | None = ()) -> None:

"""
>>> sh = SkewHeap([3, 1, 3, 7])
>>> list(sh)
Expand Down
2 changes: 0 additions & 2 deletions data_structures/linked_list/doubly_linked_list_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_tail_data(self):
return None

def set_head(self, node: Node) -> None:

if self.head is None:
self.head = node
self.tail = node
Expand Down Expand Up @@ -143,7 +142,6 @@ def get_node(self, item: int) -> Node:
raise Exception("Node not found")

def delete_value(self, value):

if (node := self.get_node(value)) is not None:
if node == self.head:
self.head = self.head.get_next()
Expand Down
1 change: 0 additions & 1 deletion data_structures/stacks/prefix_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def evaluate(expression):

# iterate over the string in reverse order
for c in expression.split()[::-1]:

# push operand to stack
if is_operand(c):
stack.append(int(c))
Expand Down
1 change: 0 additions & 1 deletion data_structures/stacks/stack_with_doubly_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def print_stack(self) -> None:

# Code execution starts here
if __name__ == "__main__":

# Start with the empty stack
stack: Stack[int] = Stack()

Expand Down
2 changes: 0 additions & 2 deletions data_structures/stacks/stock_span_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def calculation_span(price, s):

n = len(price)
# Create a stack and push index of fist element to it
st = []
Expand All @@ -20,7 +19,6 @@ def calculation_span(price, s):

# Calculate span values for rest of the elements
for i in range(1, n):

# Pop elements from stack while stack is not
# empty and top of stack is smaller than price[i]
while len(st) > 0 and price[st[0]] <= price[i]:
Expand Down
1 change: 0 additions & 1 deletion digital_image_processing/filters/bilateral_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def bilateral_filter(
size_x, size_y = img.shape
for i in range(kernel_size // 2, size_x - kernel_size // 2):
for j in range(kernel_size // 2, size_y - kernel_size // 2):

img_s = get_slice(img, i, j, kernel_size)
img_i = img_s - img_s[kernel_size // 2, kernel_size // 2]
img_ig = vec_gaussian(img_i, intensity_variance)
Expand Down
1 change: 0 additions & 1 deletion digital_image_processing/filters/local_binary_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def local_binary_value(image: np.ndarray, x_coordinate: int, y_coordinate: int)


if __name__ == "__main__":

# Reading the image and converting it to grayscale.
image = cv2.imread(
"digital_image_processing/image_data/lena.jpg", cv2.IMREAD_GRAYSCALE
Expand Down
5 changes: 0 additions & 5 deletions dynamic_programming/bitmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

class AssignmentUsingBitmask:
def __init__(self, task_performed, total):

self.total_tasks = total # total no of tasks (N)

# DP table will have a dimension of (2^M)*N
Expand All @@ -29,7 +28,6 @@ def __init__(self, task_performed, total):
self.final_mask = (1 << len(task_performed)) - 1

def count_ways_until(self, mask, task_no):

# if mask == self.finalmask all persons are distributed tasks, return 1
if mask == self.final_mask:
return 1
Expand All @@ -49,7 +47,6 @@ def count_ways_until(self, mask, task_no):
# assign for the remaining tasks.
if task_no in self.task:
for p in self.task[task_no]:

# if p is already given a task
if mask & (1 << p):
continue
Expand All @@ -64,7 +61,6 @@ def count_ways_until(self, mask, task_no):
return self.dp[mask][task_no]

def count_no_of_ways(self, task_performed):

# Store the list of persons for each task
for i in range(len(task_performed)):
for j in task_performed[i]:
Expand All @@ -75,7 +71,6 @@ def count_no_of_ways(self, task_performed):


if __name__ == "__main__":

total_tasks = 5 # total no of tasks (the value of N)

# the list of tasks that can be done by M persons.
Expand Down
1 change: 0 additions & 1 deletion dynamic_programming/iterating_through_submasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def list_of_submasks(mask: int) -> list[int]:

"""
Args:
mask : number which shows mask ( always integer > 0, zero does not have any
Expand Down
1 change: 0 additions & 1 deletion electronics/coulombs_law.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def couloumbs_law(
force: float, charge1: float, charge2: float, distance: float
) -> dict[str, float]:

"""
Apply Coulomb's Law on any three given values. These can be force, charge1,
charge2, or distance, and then in a Python dict return name/value pair of
Expand Down
1 change: 0 additions & 1 deletion fractals/julia_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def ignore_overflow_warnings() -> None:


if __name__ == "__main__":

z_0 = prepare_grid(window_size, nb_pixels)

ignore_overflow_warnings() # See file header for explanations
Expand Down
1 change: 0 additions & 1 deletion fractals/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def get_image(
# loop through the image-coordinates
for image_x in range(image_width):
for image_y in range(image_height):

# determine the figure-coordinates based on the image-coordinates
figure_height = figure_width / image_width * image_height
figure_x = figure_center_x + (image_x / image_width - 0.5) * figure_width
Expand Down
1 change: 0 additions & 1 deletion geodesy/lamberts_ellipsoidal_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def lamberts_ellipsoidal_distance(
lat1: float, lon1: float, lat2: float, lon2: float
) -> float:

"""
Calculate the shortest distance along the surface of an ellipsoid between
two points on the surface of earth given longitudes and latitudes
Expand Down
1 change: 0 additions & 1 deletion graphs/a_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def search(
cost: int,
heuristic: list[list[int]],
) -> tuple[list[list[int]], list[list[int]]]:

closed = [
[0 for col in range(len(grid[0]))] for row in range(len(grid))
] # the reference grid
Expand Down
1 change: 0 additions & 1 deletion graphs/check_bipartite_graph_bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def bfs():
visited[u] = True

for neighbour in graph[u]:

if neighbour == u:
return False

Expand Down
Loading

0 comments on commit c909da9

Please sign in to comment.