mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 05:03:07 +00:00
fix(tools): modify type-hints to be compatible with older python versions
This commit is contained in:
parent
9ca9720f22
commit
82622adf6f
@ -7,7 +7,14 @@ import os
|
||||
import re
|
||||
from collections import OrderedDict, defaultdict
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Iterable, Iterator, Literal, TypedDict, cast
|
||||
from typing import Dict # for python38 support, must be used in type aliases
|
||||
from typing import List # for python38 support, must be used in type aliases
|
||||
from typing import Any, Callable, Iterable, Iterator, cast
|
||||
|
||||
from typing_extensions import ( # for python37 support, is not present in typing there
|
||||
Literal,
|
||||
TypedDict,
|
||||
)
|
||||
|
||||
try:
|
||||
import requests
|
||||
@ -48,10 +55,10 @@ class SupportInfoItem(TypedDict):
|
||||
trezor2: Literal[False] | str
|
||||
|
||||
|
||||
SupportInfo = dict[str, SupportInfoItem]
|
||||
SupportInfo = Dict[str, SupportInfoItem]
|
||||
|
||||
WalletItems = dict[str, str]
|
||||
WalletInfo = dict[str, WalletItems]
|
||||
WalletItems = Dict[str, str]
|
||||
WalletInfo = Dict[str, WalletItems]
|
||||
|
||||
|
||||
class Coin(TypedDict):
|
||||
@ -126,8 +133,8 @@ class Coin(TypedDict):
|
||||
bitcore: list[str]
|
||||
|
||||
|
||||
Coins = list[Coin]
|
||||
CoinBuckets = dict[str, Coins]
|
||||
Coins = List[Coin]
|
||||
CoinBuckets = Dict[str, Coins]
|
||||
|
||||
|
||||
class FidoApp(TypedDict):
|
||||
@ -142,7 +149,7 @@ class FidoApp(TypedDict):
|
||||
icon: str
|
||||
|
||||
|
||||
FidoApps = list[FidoApp]
|
||||
FidoApps = List[FidoApp]
|
||||
|
||||
|
||||
def load_json(*path: str | Path) -> Any:
|
||||
@ -158,7 +165,7 @@ def load_json(*path: str | Path) -> Any:
|
||||
# ====== CoinsInfo ======
|
||||
|
||||
|
||||
class CoinsInfo(dict[str, Coins]):
|
||||
class CoinsInfo(Dict[str, Coins]):
|
||||
"""Collection of information about all known kinds of coins.
|
||||
|
||||
It contains the following lists:
|
||||
|
@ -16,6 +16,8 @@ Running the script:
|
||||
- `python generate_ci_docs.py --check` to check if documentation is up-to-date
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import filecmp
|
||||
import os
|
||||
|
@ -46,18 +46,24 @@ import sys
|
||||
import tempfile
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Final, Iterator, TypedDict
|
||||
from typing import Dict # for python38 support, must be used in type aliases
|
||||
from typing import List # for python38 support, must be used in type aliases
|
||||
from typing import TYPE_CHECKING, Any, Iterator
|
||||
from typing_extensions import ( # for python37 support, is not present in typing there
|
||||
Final,
|
||||
TypedDict,
|
||||
)
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
LineIgnores = list["LineIgnore"]
|
||||
LineIgnores = List["LineIgnore"]
|
||||
|
||||
FileIgnores = dict[str, LineIgnores]
|
||||
FileSpecificIgnores = dict[str, list["FileSpecificIgnore"]]
|
||||
FileIgnores = Dict[str, LineIgnores]
|
||||
FileSpecificIgnores = Dict[str, List["FileSpecificIgnore"]]
|
||||
|
||||
PyrightOffIgnores = list["PyrightOffIgnore"]
|
||||
FilePyrightOffIgnores = dict[str, PyrightOffIgnores]
|
||||
PyrightOffIgnores = List["PyrightOffIgnore"]
|
||||
FilePyrightOffIgnores = Dict[str, PyrightOffIgnores]
|
||||
|
||||
|
||||
class RangeDetail(TypedDict):
|
||||
|
Loading…
Reference in New Issue
Block a user