diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b666e88aa..e60003051 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,12 @@ repos: - id: isort args: - --profile=black + - repo: https://github.com/asottile/pyupgrade + rev: v2.29.0 + hooks: + - id: pyupgrade + args: + - --py39-plus - repo: https://gitlab.com/pycqa/flake8 rev: 3.9.1 hooks: diff --git a/DIRECTORY.md b/DIRECTORY.md index c94fb78d6..2acfff69d 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -126,6 +126,7 @@ * [Molecular Chemistry](https://github.com/TheAlgorithms/Python/blob/master/conversions/molecular_chemistry.py) * [Octal To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/octal_to_decimal.py) * [Prefix Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/prefix_conversions.py) + * [Pressure Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/pressure_conversions.py) * [Rgb Hsv Conversion](https://github.com/TheAlgorithms/Python/blob/master/conversions/rgb_hsv_conversion.py) * [Roman Numerals](https://github.com/TheAlgorithms/Python/blob/master/conversions/roman_numerals.py) * [Temperature Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/temperature_conversions.py) @@ -860,6 +861,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_301/sol1.py) * Problem 551 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_551/sol1.py) + * Problem 686 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_686/sol1.py) ## Quantum * [Deutsch Jozsa](https://github.com/TheAlgorithms/Python/blob/master/quantum/deutsch_jozsa.py) diff --git a/data_structures/binary_tree/merge_two_binary_trees.py b/data_structures/binary_tree/merge_two_binary_trees.py index 748726894..3380f8c5f 100644 --- a/data_structures/binary_tree/merge_two_binary_trees.py +++ b/data_structures/binary_tree/merge_two_binary_trees.py @@ -7,8 +7,6 @@ will be used as the node of new tree. """ from __future__ import annotations -from typing import Optional - class Node: """ @@ -21,7 +19,7 @@ class Node: self.right: Node | None = None -def merge_two_binary_trees(tree1: Node | None, tree2: Node | None) -> Optional[Node]: +def merge_two_binary_trees(tree1: Node | None, tree2: Node | None) -> Node | None: """ Returns root node of the merged tree. diff --git a/data_structures/linked_list/skip_list.py b/data_structures/linked_list/skip_list.py index be30592ec..176049120 100644 --- a/data_structures/linked_list/skip_list.py +++ b/data_structures/linked_list/skip_list.py @@ -5,14 +5,14 @@ https://epaperpress.com/sortsearch/download/skiplist.pdf from __future__ import annotations from random import random -from typing import Generic, Optional, TypeVar, Union +from typing import Generic, TypeVar KT = TypeVar("KT") VT = TypeVar("VT") class Node(Generic[KT, VT]): - def __init__(self, key: Union[KT, str] = "root", value: Optional[VT] = None): + def __init__(self, key: KT | str = "root", value: VT | None = None): self.key = key self.value = value self.forward: list[Node[KT, VT]] = []