GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — from __future__ import annotations (#2464) · jusing-es/Python@9200a2e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .travis.yml
  • arithmetic_analysis
    • in_static_equilibrium.py
  • backtracking
    • coloring.py
    • hamiltonian_cycle.py
    • knight_tour.py
    • n_queens_math.py
  • cellular_automata
    • one_dimensional.py
  • ciphers
    • rsa_factorization.py
  • compression
    • burrows_wheeler.py
  • data_structures
    • binary_tree
      • lazy_segment_tree.py
      • lowest_common_ancestor.py
      • non_recursive_segment_tree.py
      • treap.py
    • linked_list
      • skip_list.py
  • divide_and_conquer
    • strassen_matrix_multiplication.py
  • dynamic_programming
    • fast_fibonacci.py
    • fractional_knapsack_2.py
    • iterating_through_submasks.py
    • longest_increasing_subsequence.py
    • longest_increasing_subsequence_o(nlogn).py
    • max_non_adjacent_sum.py
    • max_sub_array.py
    • minimum_cost_path.py
  • genetic_algorithm
    • basic_string.py
  • graphics
    • bezier_curve.py
  • graphs
    • bellman_ford.py
    • bidirectional_a_star.py
    • bidirectional_breadth_first_search.py
    • breadth_first_search_2.py
    • breadth_first_search_shortest_path.py
    • depth_first_search.py
    • gale_shapley_bigraph.py
    • greedy_best_first.py
    • karger.py
    • prim.py
  • linear_algebra/src
    • polynom_for_points.py
    • transformations_2d.py
  • maths
    • 3n_plus_1.py
    • abs_max.py
    • allocation_number.py
    • collatz_sequence.py
    • entropy.py
    • is_square_free.py
    • line_length.py
    • monte_carlo_dice.py
    • prime_factors.py
    • quadratic_equations_complex_numbers.py
    • relu.py
  • matrix
    • inverse_of_matrix.py
    • matrix_operation.py
    • searching_in_sorted_matrix.py
  • other
    • dijkstra_bankers_algorithm.py
    • markov_chain.py
    • triplet_sum.py
  • project_euler
    • problem_35
      • sol1.py
    • problem_37
      • sol1.py
    • problem_39
      • sol1.py
    • problem_41
      • sol1.py
    • problem_46
      • sol1.py
    • problem_54
      • sol1.py
  • scheduling
    • first_come_first_served.py
    • round_robin.py
    • shortest_job_first.py
  • searches
    • double_linear_search.py
    • simple_binary_search.py
  • sorts
    • iterative_merge_sort.py
    • merge_insertion_sort.py
    • radix_sort.py
    • recursive_insertion_sort.py
  • traversals
    • binary_tree_traversals.py
  • web_programming
    • fetch_jobs.py
    • get_imdb_top_250_movies_csv.py

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.travis.yml‎

Copy file name to clipboardExpand all lines: .travis.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory
1515
- pip install -r requirements.txt # fast fail on black, flake8, validate_filenames
1616
script:
17-
- mypy --ignore-missing-imports .
17+
- mypy --ignore-missing-imports . || true # https://github.com/python/mypy/issues/7907
1818
- pytest --doctest-modules --ignore=project_euler/ --durations=10 --cov-report=term-missing:skip-covered --cov=. .
1919
- name: Project Euler
2020
before_script: pip install pytest-cov
2121
script:
2222
- pytest --doctest-modules --durations=10 --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
23+
after_success:
24+
- scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
2325
notifications:
2426
webhooks: https://www.travisbuddy.com/
2527
on_success: never
26-
after_success:
27-
- scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
Collapse file

‎arithmetic_analysis/in_static_equilibrium.py‎

Copy file name to clipboardExpand all lines: arithmetic_analysis/in_static_equilibrium.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
mypy : passed
77
"""
88

9-
from typing import List
9+
from __future__ import annotations
1010

1111
from numpy import array, cos, cross, radians, sin # type: ignore
1212

1313

1414
def polar_force(
1515
magnitude: float, angle: float, radian_mode: bool = False
16-
) -> List[float]:
16+
) -> list[float]:
1717
"""
1818
Resolves force along rectangular components.
1919
(force, angle) => (force_x, force_y)
Collapse file

‎backtracking/coloring.py‎

Copy file name to clipboardExpand all lines: backtracking/coloring.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
66
Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring
77
"""
8-
from typing import List
8+
from __future__ import annotations
99

1010

1111
def valid_coloring(
12-
neighbours: List[int], colored_vertices: List[int], color: int
12+
neighbours: list[int], colored_vertices: list[int], color: int
1313
) -> bool:
1414
"""
1515
For each neighbour check if coloring constraint is satisfied
@@ -35,7 +35,7 @@ def valid_coloring(
3535

3636

3737
def util_color(
38-
graph: List[List[int]], max_colors: int, colored_vertices: List[int], index: int
38+
graph: list[list[int]], max_colors: int, colored_vertices: list[int], index: int
3939
) -> bool:
4040
"""
4141
Pseudo-Code
@@ -86,7 +86,7 @@ def util_color(
8686
return False
8787

8888

89-
def color(graph: List[List[int]], max_colors: int) -> List[int]:
89+
def color(graph: list[list[int]], max_colors: int) -> list[int]:
9090
"""
9191
Wrapper function to call subroutine called util_color
9292
which will either return True or False.
Collapse file

‎backtracking/hamiltonian_cycle.py‎

Copy file name to clipboardExpand all lines: backtracking/hamiltonian_cycle.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
77
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
88
"""
9-
from typing import List
9+
from __future__ import annotations
1010

1111

1212
def valid_connection(
13-
graph: List[List[int]], next_ver: int, curr_ind: int, path: List[int]
13+
graph: list[list[int]], next_ver: int, curr_ind: int, path: list[int]
1414
) -> bool:
1515
"""
1616
Checks whether it is possible to add next into path by validating 2 statements
@@ -47,7 +47,7 @@ def valid_connection(
4747
return not any(vertex == next_ver for vertex in path)
4848

4949

50-
def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int) -> bool:
50+
def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int) -> bool:
5151
"""
5252
Pseudo-Code
5353
Base Case:
@@ -108,7 +108,7 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
108108
return False
109109

110110

111-
def hamilton_cycle(graph: List[List[int]], start_index: int = 0) -> List[int]:
111+
def hamilton_cycle(graph: list[list[int]], start_index: int = 0) -> list[int]:
112112
r"""
113113
Wrapper function to call subroutine called util_hamilton_cycle,
114114
which will either return array of vertices indicating hamiltonian cycle
Collapse file

‎backtracking/knight_tour.py‎

Copy file name to clipboardExpand all lines: backtracking/knight_tour.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Knight Tour Intro: https://www.youtube.com/watch?v=ab_dY3dZFHM
22

3-
from typing import List, Tuple
3+
from __future__ import annotations
44

55

6-
def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:
6+
def get_valid_pos(position: tuple[int], n: int) -> list[tuple[int]]:
77
"""
88
Find all the valid positions a knight can move to from the current position.
99
@@ -32,7 +32,7 @@ def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:
3232
return permissible_positions
3333

3434

35-
def is_complete(board: List[List[int]]) -> bool:
35+
def is_complete(board: list[list[int]]) -> bool:
3636
"""
3737
Check if the board (matrix) has been completely filled with non-zero values.
3838
@@ -46,7 +46,7 @@ def is_complete(board: List[List[int]]) -> bool:
4646
return not any(elem == 0 for row in board for elem in row)
4747

4848

49-
def open_knight_tour_helper(board: List[List[int]], pos: Tuple[int], curr: int) -> bool:
49+
def open_knight_tour_helper(board: list[list[int]], pos: tuple[int], curr: int) -> bool:
5050
"""
5151
Helper function to solve knight tour problem.
5252
"""
@@ -66,7 +66,7 @@ def open_knight_tour_helper(board: List[List[int]], pos: Tuple[int], curr: int)
6666
return False
6767

6868

69-
def open_knight_tour(n: int) -> List[List[int]]:
69+
def open_knight_tour(n: int) -> list[list[int]]:
7070
"""
7171
Find the solution for the knight tour problem for a board of size n. Raises
7272
ValueError if the tour cannot be performed for the given size.
Collapse file

‎backtracking/n_queens_math.py‎

Copy file name to clipboardExpand all lines: backtracking/n_queens_math.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
for another one or vice versa.
7676
7777
"""
78-
from typing import List
78+
from __future__ import annotations
7979

8080

8181
def depth_first_search(
82-
possible_board: List[int],
83-
diagonal_right_collisions: List[int],
84-
diagonal_left_collisions: List[int],
85-
boards: List[List[str]],
82+
possible_board: list[int],
83+
diagonal_right_collisions: list[int],
84+
diagonal_left_collisions: list[int],
85+
boards: list[list[str]],
8686
n: int,
8787
) -> None:
8888
"""
Collapse file

‎cellular_automata/one_dimensional.py‎

Copy file name to clipboardExpand all lines: cellular_automata/one_dimensional.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
55
"""
66

7-
from typing import List
7+
from __future__ import annotations
88

99
from PIL import Image
1010

@@ -15,7 +15,7 @@
1515
# fmt: on
1616

1717

18-
def format_ruleset(ruleset: int) -> List[int]:
18+
def format_ruleset(ruleset: int) -> list[int]:
1919
"""
2020
>>> format_ruleset(11100)
2121
[0, 0, 0, 1, 1, 1, 0, 0]
@@ -27,7 +27,7 @@ def format_ruleset(ruleset: int) -> List[int]:
2727
return [int(c) for c in f"{ruleset:08}"[:8]]
2828

2929

30-
def new_generation(cells: List[List[int]], rule: List[int], time: int) -> List[int]:
30+
def new_generation(cells: list[list[int]], rule: list[int], time: int) -> list[int]:
3131
population = len(cells[0]) # 31
3232
next_generation = []
3333
for i in range(population):
@@ -41,7 +41,7 @@ def new_generation(cells: List[List[int]], rule: List[int], time: int) -> List[i
4141
return next_generation
4242

4343

44-
def generate_image(cells: List[List[int]]) -> Image.Image:
44+
def generate_image(cells: list[list[int]]) -> Image.Image:
4545
"""
4646
Convert the cells into a greyscale PIL.Image.Image and return it to the caller.
4747
>>> from random import random
Collapse file

‎ciphers/rsa_factorization.py‎

Copy file name to clipboardExpand all lines: ciphers/rsa_factorization.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
More readable source: https://www.di-mgt.com.au/rsa_factorize_n.html
88
large number can take minutes to factor, therefore are not included in doctest.
99
"""
10+
from __future__ import annotations
11+
1012
import math
1113
import random
12-
from typing import List
1314

1415

15-
def rsafactor(d: int, e: int, N: int) -> List[int]:
16+
def rsafactor(d: int, e: int, N: int) -> list[int]:
1617
"""
1718
This function returns the factors of N, where p*q=N
1819
Return: [p, q]
Collapse file

‎compression/burrows_wheeler.py‎

Copy file name to clipboardExpand all lines: compression/burrows_wheeler.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
original character. The BWT is thus a "free" method of improving the efficiency
1111
of text compression algorithms, costing only some extra computation.
1212
"""
13-
from typing import Dict, List
13+
from __future__ import annotations
1414

1515

16-
def all_rotations(s: str) -> List[str]:
16+
def all_rotations(s: str) -> list[str]:
1717
"""
1818
:param s: The string that will be rotated len(s) times.
1919
:return: A list with the rotations.
@@ -43,7 +43,7 @@ def all_rotations(s: str) -> List[str]:
4343
return [s[i:] + s[:i] for i in range(len(s))]
4444

4545

46-
def bwt_transform(s: str) -> Dict:
46+
def bwt_transform(s: str) -> dict:
4747
"""
4848
:param s: The string that will be used at bwt algorithm
4949
:return: the string composed of the last char of each row of the ordered
Collapse file

‎data_structures/binary_tree/lazy_segment_tree.py‎

Copy file name to clipboardExpand all lines: data_structures/binary_tree/lazy_segment_tree.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from __future__ import annotations
2+
13
import math
2-
from typing import List
34

45

56
class SegmentTree:
@@ -36,7 +37,7 @@ def right(self, idx: int) -> int:
3637
return idx * 2 + 1
3738

3839
def build(
39-
self, idx: int, left_element: int, right_element: int, A: List[int]
40+
self, idx: int, left_element: int, right_element: int, A: list[int]
4041
) -> None:
4142
if left_element == right_element:
4243
self.segment_tree[idx] = A[left_element - 1]

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.