mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 (#6245)
* pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 * pre-commit run --all-files
This commit is contained in:
parent
2d5dd6f132
commit
b75a7c77f8
|
@ -26,7 +26,7 @@ repos:
|
|||
- --profile=black
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.34.0
|
||||
rev: v2.37.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def bisection(function: Callable[[float], float], a: float, b: float) -> float:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import math
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def intersection(function: Callable[[float], float], x0: float, x1: float) -> float:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Newton's Method."""
|
||||
|
||||
# Newton's Method - https://en.wikipedia.org/wiki/Newton%27s_method
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
RealFunc = Callable[[float], float] # type alias for a real -> real function
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
|
||||
def compare_string(string1: str, string2: str) -> str:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import itertools
|
||||
import string
|
||||
from typing import Generator, Iterable
|
||||
from collections.abc import Generator, Iterable
|
||||
|
||||
|
||||
def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]:
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
Paper: http://image.diku.dk/imagecanon/material/HornSchunckOptical_Flow.pdf
|
||||
"""
|
||||
|
||||
from typing import SupportsIndex
|
||||
|
||||
import numpy as np
|
||||
from scipy.ndimage.filters import convolve
|
||||
from typing_extensions import SupportsIndex
|
||||
|
||||
|
||||
def warp(
|
||||
|
|
|
@ -10,7 +10,7 @@ python binary_search_tree_recursive.py
|
|||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from typing import Iterator
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
||||
class Node:
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Sequence
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -37,7 +37,8 @@ https://www.geeksforgeeks.org/segment-tree-efficient-implementation/
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Generic, TypeVar
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ flake8 : passed
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterator
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
||||
class RedBlackTree:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class Heap:
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
from typing import Any, Generic, Iterable, TypeVar
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
T = TypeVar("T", bound=bool)
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Generic, Iterable, Iterator, TypeVar
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
T = TypeVar("T", bound=bool)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterator
|
||||
from collections.abc import Iterator
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Node:
|
||||
|
|
|
@ -3,8 +3,9 @@ Implementation of double ended queue.
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Iterable
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Deque:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
""" A Queue using a linked list like structure """
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterator
|
||||
from collections.abc import Iterator
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Node:
|
||||
|
|
|
@ -14,7 +14,7 @@ which have not been implemented here, yet.
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class Point:
|
||||
|
|
|
@ -22,7 +22,8 @@ Remark: Some overflow runtime warnings are suppressed. This is because of the
|
|||
"""
|
||||
|
||||
import warnings
|
||||
from typing import Any, Callable
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
import numpy
|
||||
from matplotlib import pyplot
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import heapq as hq
|
||||
import math
|
||||
from typing import Iterator
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
||||
class Vertex:
|
||||
|
|
|
@ -22,7 +22,8 @@ from __future__ import annotations
|
|||
|
||||
import math
|
||||
import random
|
||||
from typing import Collection, overload
|
||||
from collections.abc import Collection
|
||||
from typing import overload
|
||||
|
||||
|
||||
class Vector:
|
||||
|
|
|
@ -42,10 +42,11 @@
|
|||
|
||||
Author: @EverLookNeverSee
|
||||
"""
|
||||
from collections.abc import Callable
|
||||
from math import log
|
||||
from os import name, system
|
||||
from random import gauss, seed
|
||||
from typing import Callable, TypeVar
|
||||
from typing import TypeVar
|
||||
|
||||
|
||||
# Make a training dataset drawn from a gaussian distribution
|
||||
|
|
|
@ -3,7 +3,7 @@ Approximates the area under the curve using the trapezoidal rule
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def trapezoidal_area(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable, Union
|
||||
from collections.abc import Iterable
|
||||
from typing import Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def line_length(
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
"""
|
||||
@author: MatteoRaso
|
||||
"""
|
||||
from collections.abc import Callable
|
||||
from math import pi, sqrt
|
||||
from random import uniform
|
||||
from statistics import mean
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def pi_estimator(iterations: int):
|
||||
|
|
|
@ -3,7 +3,7 @@ Approximates the area under the curve using the trapezoidal rule
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
def trapezoidal_area(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
|
||||
def evaluate_poly(poly: Sequence[float], x: float) -> float:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import math
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
|
||||
def slow_primes(max: int) -> Generator[int, None, None]:
|
||||
|
|
|
@ -11,7 +11,7 @@ For more information about the algorithm: https://en.wikipedia.org/wiki/DPLL_alg
|
|||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
from typing import Iterable
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class Clause:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Generic, TypeVar
|
||||
from collections.abc import Callable
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Generic, TypeVar
|
||||
from collections.abc import Callable
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
|
|
@ -11,8 +11,8 @@ References:
|
|||
- https://en.wikipedia.org/wiki/Prime_number
|
||||
"""
|
||||
import math
|
||||
from collections.abc import Iterator
|
||||
from itertools import takewhile
|
||||
from typing import Iterator
|
||||
|
||||
|
||||
def is_prime(number: int) -> bool:
|
||||
|
|
|
@ -23,7 +23,7 @@ The 12th term, F12, is the first term to contain three digits.
|
|||
What is the index of the first term in the Fibonacci sequence to contain 1000
|
||||
digits?
|
||||
"""
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
|
||||
def fibonacci_generator() -> Generator[int, None, None]:
|
||||
|
|
|
@ -43,7 +43,8 @@ Find the sum of FITs for the BOPs.
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Union
|
||||
from collections.abc import Callable
|
||||
from typing import Union
|
||||
|
||||
Matrix = list[list[Union[float, int]]]
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ Solution:
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Mapping
|
||||
from collections.abc import Mapping
|
||||
|
||||
EdgeT = tuple[int, int]
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ So it could be simplified as,
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
|
||||
def sieve() -> Generator[int, None, None]:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
from typing import Iterator
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
||||
def good_file_paths(top_dir: str = ".") -> Iterator[str]:
|
||||
|
|
|
@ -3,7 +3,7 @@ Scraping jobs given job title and location from indeed website
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
|
Loading…
Reference in New Issue
Block a user