Skip to content

Commit b75a7c7

Browse files
authored
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
1 parent 2d5dd6f commit b75a7c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+56
-41
lines changed

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- --profile=black
2727

2828
- repo: https://github.com/asottile/pyupgrade
29-
rev: v2.34.0
29+
rev: v2.37.0
3030
hooks:
3131
- id: pyupgrade
3232
args:

Diff for: arithmetic_analysis/bisection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33

44
def bisection(function: Callable[[float], float], a: float, b: float) -> float:

Diff for: arithmetic_analysis/intersection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import math
2-
from typing import Callable
2+
from collections.abc import Callable
33

44

55
def intersection(function: Callable[[float], float], x0: float, x1: float) -> float:

Diff for: arithmetic_analysis/newton_method.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Newton's Method."""
22

33
# Newton's Method - https://en.wikipedia.org/wiki/Newton%27s_method
4-
from typing import Callable
4+
from collections.abc import Callable
55

66
RealFunc = Callable[[float], float] # type alias for a real -> real function
77

Diff for: boolean_algebra/quine_mc_cluskey.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Sequence
3+
from collections.abc import Sequence
44

55

66
def compare_string(string1: str, string2: str) -> str:

Diff for: ciphers/playfair_cipher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import itertools
22
import string
3-
from typing import Generator, Iterable
3+
from collections.abc import Generator, Iterable
44

55

66
def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]:

Diff for: computer_vision/horn_schunck.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
Paper: http://image.diku.dk/imagecanon/material/HornSchunckOptical_Flow.pdf
1010
"""
1111

12+
from typing import SupportsIndex
13+
1214
import numpy as np
1315
from scipy.ndimage.filters import convolve
14-
from typing_extensions import SupportsIndex
1516

1617

1718
def warp(

Diff for: data_structures/binary_tree/binary_search_tree_recursive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from __future__ import annotations
1111

1212
import unittest
13-
from typing import Iterator
13+
from collections.abc import Iterator
1414

1515

1616
class Node:

Diff for: data_structures/binary_tree/binary_tree_traversals.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
from __future__ import annotations
33

44
from collections import deque
5+
from collections.abc import Sequence
56
from dataclasses import dataclass
6-
from typing import Any, Sequence
7+
from typing import Any
78

89

910
@dataclass

Diff for: data_structures/binary_tree/non_recursive_segment_tree.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"""
3838
from __future__ import annotations
3939

40-
from typing import Any, Callable, Generic, TypeVar
40+
from collections.abc import Callable
41+
from typing import Any, Generic, TypeVar
4142

4243
T = TypeVar("T")
4344

Diff for: data_structures/binary_tree/red_black_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
from __future__ import annotations
66

7-
from typing import Iterator
7+
from collections.abc import Iterator
88

99

1010
class RedBlackTree:

Diff for: data_structures/heap/heap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Iterable
3+
from collections.abc import Iterable
44

55

66
class Heap:

Diff for: data_structures/heap/randomized_heap.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from __future__ import annotations
44

55
import random
6-
from typing import Any, Generic, Iterable, TypeVar
6+
from collections.abc import Iterable
7+
from typing import Any, Generic, TypeVar
78

89
T = TypeVar("T", bound=bool)
910

Diff for: data_structures/heap/skew_heap.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Generic, Iterable, Iterator, TypeVar
5+
from collections.abc import Iterable, Iterator
6+
from typing import Any, Generic, TypeVar
67

78
T = TypeVar("T", bound=bool)
89

Diff for: data_structures/linked_list/circular_linked_list.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Any, Iterator
3+
from collections.abc import Iterator
4+
from typing import Any
45

56

67
class Node:

Diff for: data_structures/queue/double_ended_queue.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"""
44
from __future__ import annotations
55

6+
from collections.abc import Iterable
67
from dataclasses import dataclass
7-
from typing import Any, Iterable
8+
from typing import Any
89

910

1011
class Deque:

Diff for: data_structures/queue/linked_queue.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
""" A Queue using a linked list like structure """
22
from __future__ import annotations
33

4-
from typing import Any, Iterator
4+
from collections.abc import Iterator
5+
from typing import Any
56

67

78
class Node:

Diff for: divide_and_conquer/convex_hull.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
from __future__ import annotations
1616

17-
from typing import Iterable
17+
from collections.abc import Iterable
1818

1919

2020
class Point:

Diff for: fractals/julia_sets.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"""
2323

2424
import warnings
25-
from typing import Any, Callable
25+
from collections.abc import Callable
26+
from typing import Any
2627

2728
import numpy
2829
from matplotlib import pyplot

Diff for: graphs/prim.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import heapq as hq
99
import math
10-
from typing import Iterator
10+
from collections.abc import Iterator
1111

1212

1313
class Vertex:

Diff for: linear_algebra/src/lib.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
import math
2424
import random
25-
from typing import Collection, overload
25+
from collections.abc import Collection
26+
from typing import overload
2627

2728

2829
class Vector:

Diff for: machine_learning/linear_discriminant_analysis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
4242
4343
Author: @EverLookNeverSee
4444
"""
45+
from collections.abc import Callable
4546
from math import log
4647
from os import name, system
4748
from random import gauss, seed
48-
from typing import Callable, TypeVar
49+
from typing import TypeVar
4950

5051

5152
# Make a training dataset drawn from a gaussian distribution

Diff for: maths/area_under_curve.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import Callable
6+
from collections.abc import Callable
77

88

99
def trapezoidal_area(

Diff for: maths/euclidean_distance.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Iterable, Union
3+
from collections.abc import Iterable
4+
from typing import Union
45

56
import numpy as np
67

Diff for: maths/euler_method.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33
import numpy as np
44

Diff for: maths/euler_modified.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33
import numpy as np
44

Diff for: maths/line_length.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import math
4-
from typing import Callable
4+
from collections.abc import Callable
55

66

77
def line_length(

Diff for: maths/monte_carlo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""
22
@author: MatteoRaso
33
"""
4+
from collections.abc import Callable
45
from math import pi, sqrt
56
from random import uniform
67
from statistics import mean
7-
from typing import Callable
88

99

1010
def pi_estimator(iterations: int):

Diff for: maths/numerical_integration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import Callable
6+
from collections.abc import Callable
77

88

99
def trapezoidal_area(

Diff for: maths/polynomial_evaluation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33

44
def evaluate_poly(poly: Sequence[float], x: float) -> float:

Diff for: maths/prime_numbers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import math
2-
from typing import Generator
2+
from collections.abc import Generator
33

44

55
def slow_primes(max: int) -> Generator[int, None, None]:

Diff for: other/davisb_putnamb_logemannb_loveland.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__ import annotations
1212

1313
import random
14-
from typing import Iterable
14+
from collections.abc import Iterable
1515

1616

1717
class Clause:

Diff for: other/lfu_cache.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Callable, Generic, TypeVar
3+
from collections.abc import Callable
4+
from typing import Generic, TypeVar
45

56
T = TypeVar("T")
67
U = TypeVar("U")

Diff for: other/lru_cache.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Callable, Generic, TypeVar
3+
from collections.abc import Callable
4+
from typing import Generic, TypeVar
45

56
T = TypeVar("T")
67
U = TypeVar("U")

Diff for: project_euler/problem_010/sol2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
- https://en.wikipedia.org/wiki/Prime_number
1212
"""
1313
import math
14+
from collections.abc import Iterator
1415
from itertools import takewhile
15-
from typing import Iterator
1616

1717

1818
def is_prime(number: int) -> bool:

Diff for: project_euler/problem_025/sol2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
What is the index of the first term in the Fibonacci sequence to contain 1000
2424
digits?
2525
"""
26-
from typing import Generator
26+
from collections.abc import Generator
2727

2828

2929
def fibonacci_generator() -> Generator[int, None, None]:

Diff for: project_euler/problem_101/sol1.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"""
4444
from __future__ import annotations
4545

46-
from typing import Callable, Union
46+
from collections.abc import Callable
47+
from typing import Union
4748

4849
Matrix = list[list[Union[float, int]]]
4950

Diff for: project_euler/problem_107/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from __future__ import annotations
3131

3232
import os
33-
from typing import Mapping
33+
from collections.abc import Mapping
3434

3535
EdgeT = tuple[int, int]
3636

Diff for: project_euler/problem_123/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"""
4040
from __future__ import annotations
4141

42-
from typing import Generator
42+
from collections.abc import Generator
4343

4444

4545
def sieve() -> Generator[int, None, None]:

Diff for: scripts/build_directory_md.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4-
from typing import Iterator
4+
from collections.abc import Iterator
55

66

77
def good_file_paths(top_dir: str = ".") -> Iterator[str]:

Diff for: web_programming/fetch_jobs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import Generator
6+
from collections.abc import Generator
77

88
import requests
99
from bs4 import BeautifulSoup

0 commit comments

Comments
 (0)