From 224f85407581b37447eeb1a725abd13e1b6a6b62 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 5 Oct 2021 06:08:17 +0000 Subject: [PATCH 1/2] updating DIRECTORY.md --- DIRECTORY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 2e9942b5bf93..505ae0a26930 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -274,6 +274,7 @@ * [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py) ## Fractals + * [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py) * [Koch Snowflake](https://github.com/TheAlgorithms/Python/blob/master/fractals/koch_snowflake.py) * [Mandelbrot](https://github.com/TheAlgorithms/Python/blob/master/fractals/mandelbrot.py) * [Sierpinski Triangle](https://github.com/TheAlgorithms/Python/blob/master/fractals/sierpinski_triangle.py) @@ -424,10 +425,12 @@ * [Binomial Distribution](https://github.com/TheAlgorithms/Python/blob/master/maths/binomial_distribution.py) * [Bisection](https://github.com/TheAlgorithms/Python/blob/master/maths/bisection.py) * [Ceil](https://github.com/TheAlgorithms/Python/blob/master/maths/ceil.py) + * [Check Polygon](https://github.com/TheAlgorithms/Python/blob/master/maths/check_polygon.py) * [Chudnovsky Algorithm](https://github.com/TheAlgorithms/Python/blob/master/maths/chudnovsky_algorithm.py) * [Collatz Sequence](https://github.com/TheAlgorithms/Python/blob/master/maths/collatz_sequence.py) * [Combinations](https://github.com/TheAlgorithms/Python/blob/master/maths/combinations.py) * [Decimal Isolate](https://github.com/TheAlgorithms/Python/blob/master/maths/decimal_isolate.py) + * [Double Factorial Iterative](https://github.com/TheAlgorithms/Python/blob/master/maths/double_factorial_iterative.py) * [Double Factorial Recursive](https://github.com/TheAlgorithms/Python/blob/master/maths/double_factorial_recursive.py) * [Entropy](https://github.com/TheAlgorithms/Python/blob/master/maths/entropy.py) * [Euclidean Distance](https://github.com/TheAlgorithms/Python/blob/master/maths/euclidean_distance.py) From 91b44f2b034b14cfc201b551d9018c5f68b6cfaf Mon Sep 17 00:00:00 2001 From: Archaengel Date: Wed, 6 Oct 2021 00:07:25 -0700 Subject: [PATCH 2/2] Fix type annotations for linked_list/__init__.py --- data_structures/linked_list/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/data_structures/linked_list/__init__.py b/data_structures/linked_list/__init__.py index a5f5537b1d96..8d6db4e80ecd 100644 --- a/data_structures/linked_list/__init__.py +++ b/data_structures/linked_list/__init__.py @@ -6,28 +6,31 @@ - Last node: points to null """ -from typing import Any +from typing import Generic, Optional, TypeVar +T = TypeVar("T") -class Node: - def __init__(self, item: Any, next: Any) -> None: + +class Node(Generic[T]): + def __init__(self, item: T, next: Optional["Node[T]"]) -> None: self.item = item self.next = next -class LinkedList: +class LinkedList(Generic[T]): def __init__(self) -> None: - self.head = None + self.head: Optional[Node[T]] = None self.size = 0 - def add(self, item: Any) -> None: + def add(self, item: T) -> None: self.head = Node(item, self.head) self.size += 1 - def remove(self) -> Any: + def remove(self) -> Optional[T]: if self.is_empty(): return None else: + assert self.head is not None item = self.head.item self.head = self.head.next self.size -= 1