chore: use only list and not List

This commit is contained in:
ChillerDragon 2024-04-19 09:03:30 +08:00
parent 102c11acad
commit 5ef77a77a2
2 changed files with 12 additions and 10 deletions

View file

@ -24,6 +24,10 @@ find . -not -path './venv/*' -type f -name '*.sh' -print0 | xargs -0 shellcheck
pytest . || err "pytest failed!"
pylint twnet_parser/ || err "pylint failed!"
mypy twnet_parser/ || err "mypy failed!"
if grep -r 'List\[' twnet_parser tests/
then
err "found usage of List[ please use list[ instead"
fi
printf "\n%b%s%b\n" "$GREEN" "✅ all tests passed." "$RESET"

View file

@ -1,8 +1,6 @@
# https://github.com/edg-l/TeeAI/blob/18ae5eac39e82a882e751c01df2f3b1896e6ba4c/engine/huffman.py
# <Ryozuki> assume its agpl
from typing import List
FREQ_TABLE = [
1 << 30, 4545, 2657, 431, 1950, 919, 444, 482, 2244,
617, 838, 542, 715, 1814, 304, 240, 754, 212, 647, 186,
@ -60,10 +58,10 @@ class HuffmanConstructNode:
class Huffman:
def __init__(self, frequencies: List[int]):
self.nodes: List[Node] = [Node() for _ in range(HUFFMAN_MAX_NODES)]
def __init__(self, frequencies: list[int]):
self.nodes: list[Node] = [Node() for _ in range(HUFFMAN_MAX_NODES)]
# list of index of nodes
self.decode_lut: List[int] = [0 for _ in range(HUFFMAN_LUTSIZE)]
self.decode_lut: list[int] = [0 for _ in range(HUFFMAN_LUTSIZE)]
self.num_nodes: int
self.start_node_index: int
@ -102,8 +100,8 @@ class Huffman:
@staticmethod
def bubble_sort(
index_list: List[int],
node_list: List[HuffmanConstructNode],
index_list: list[int],
node_list: list[HuffmanConstructNode],
size: int
):
changed = True
@ -118,10 +116,10 @@ class Huffman:
size -= 1
return index_list
def construct_tree(self, frequencies: List[int]):
nodes_left_storage: List[HuffmanConstructNode] = [
def construct_tree(self, frequencies: list[int]):
nodes_left_storage: list[HuffmanConstructNode] = [
HuffmanConstructNode() for _ in range(HUFFMAN_MAX_SYMBOLS)]
nodes_left: List[int] = [0 for _ in range(HUFFMAN_MAX_SYMBOLS)]
nodes_left: list[int] = [0 for _ in range(HUFFMAN_MAX_SYMBOLS)]
num_nodes_left = HUFFMAN_MAX_SYMBOLS
for i in range(HUFFMAN_MAX_SYMBOLS):