From 7b5a1432812c963f75cf9cef51d8e1e6213df2eb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 28 Oct 2021 16:36:09 +0200 Subject: [PATCH 1/3] Add pyupgrade to pre-commit --- .pre-commit-config.yaml | 6 ++++++ data_structures/binary_tree/merge_two_binary_trees.py | 2 +- data_structures/linked_list/skip_list.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b666e88aa162..e60003051365 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/data_structures/binary_tree/merge_two_binary_trees.py b/data_structures/binary_tree/merge_two_binary_trees.py index 7487268940d3..fd9e04c13411 100644 --- a/data_structures/binary_tree/merge_two_binary_trees.py +++ b/data_structures/binary_tree/merge_two_binary_trees.py @@ -21,7 +21,7 @@ def __init__(self, value: int = 0) -> None: 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 be30592ec77d..1804b2f8158d 100644 --- a/data_structures/linked_list/skip_list.py +++ b/data_structures/linked_list/skip_list.py @@ -12,7 +12,7 @@ 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]] = [] From b24d204d4bce4699f43576f7af0cb47925a940ad Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 28 Oct 2021 16:42:13 +0200 Subject: [PATCH 2/3] Remove unused imports --- data_structures/binary_tree/merge_two_binary_trees.py | 2 -- data_structures/linked_list/skip_list.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/data_structures/binary_tree/merge_two_binary_trees.py b/data_structures/binary_tree/merge_two_binary_trees.py index fd9e04c13411..3380f8c5fb31 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 @@ """ from __future__ import annotations -from typing import Optional - class Node: """ diff --git a/data_structures/linked_list/skip_list.py b/data_structures/linked_list/skip_list.py index 1804b2f8158d..176049120aab 100644 --- a/data_structures/linked_list/skip_list.py +++ b/data_structures/linked_list/skip_list.py @@ -5,7 +5,7 @@ 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") From e6b32aa3808b8775bb9806f939d6ec208de0815d Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 28 Oct 2021 14:42:40 +0000 Subject: [PATCH 3/3] updating DIRECTORY.md --- DIRECTORY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index c94fb78d6275..2acfff69dff4 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)