mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-12 00:10:58 +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
|
import re
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import OrderedDict, defaultdict
|
||||||
from pathlib import Path
|
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:
|
try:
|
||||||
import requests
|
import requests
|
||||||
@ -48,10 +55,10 @@ class SupportInfoItem(TypedDict):
|
|||||||
trezor2: Literal[False] | str
|
trezor2: Literal[False] | str
|
||||||
|
|
||||||
|
|
||||||
SupportInfo = dict[str, SupportInfoItem]
|
SupportInfo = Dict[str, SupportInfoItem]
|
||||||
|
|
||||||
WalletItems = dict[str, str]
|
WalletItems = Dict[str, str]
|
||||||
WalletInfo = dict[str, WalletItems]
|
WalletInfo = Dict[str, WalletItems]
|
||||||
|
|
||||||
|
|
||||||
class Coin(TypedDict):
|
class Coin(TypedDict):
|
||||||
@ -126,8 +133,8 @@ class Coin(TypedDict):
|
|||||||
bitcore: list[str]
|
bitcore: list[str]
|
||||||
|
|
||||||
|
|
||||||
Coins = list[Coin]
|
Coins = List[Coin]
|
||||||
CoinBuckets = dict[str, Coins]
|
CoinBuckets = Dict[str, Coins]
|
||||||
|
|
||||||
|
|
||||||
class FidoApp(TypedDict):
|
class FidoApp(TypedDict):
|
||||||
@ -142,7 +149,7 @@ class FidoApp(TypedDict):
|
|||||||
icon: str
|
icon: str
|
||||||
|
|
||||||
|
|
||||||
FidoApps = list[FidoApp]
|
FidoApps = List[FidoApp]
|
||||||
|
|
||||||
|
|
||||||
def load_json(*path: str | Path) -> Any:
|
def load_json(*path: str | Path) -> Any:
|
||||||
@ -158,7 +165,7 @@ def load_json(*path: str | Path) -> Any:
|
|||||||
# ====== CoinsInfo ======
|
# ====== CoinsInfo ======
|
||||||
|
|
||||||
|
|
||||||
class CoinsInfo(dict[str, Coins]):
|
class CoinsInfo(Dict[str, Coins]):
|
||||||
"""Collection of information about all known kinds of coins.
|
"""Collection of information about all known kinds of coins.
|
||||||
|
|
||||||
It contains the following lists:
|
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
|
- `python generate_ci_docs.py --check` to check if documentation is up-to-date
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import filecmp
|
import filecmp
|
||||||
import os
|
import os
|
||||||
|
@ -46,18 +46,24 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
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
|
import click
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
LineIgnores = list["LineIgnore"]
|
LineIgnores = List["LineIgnore"]
|
||||||
|
|
||||||
FileIgnores = dict[str, LineIgnores]
|
FileIgnores = Dict[str, LineIgnores]
|
||||||
FileSpecificIgnores = dict[str, list["FileSpecificIgnore"]]
|
FileSpecificIgnores = Dict[str, List["FileSpecificIgnore"]]
|
||||||
|
|
||||||
PyrightOffIgnores = list["PyrightOffIgnore"]
|
PyrightOffIgnores = List["PyrightOffIgnore"]
|
||||||
FilePyrightOffIgnores = dict[str, PyrightOffIgnores]
|
FilePyrightOffIgnores = Dict[str, PyrightOffIgnores]
|
||||||
|
|
||||||
|
|
||||||
class RangeDetail(TypedDict):
|
class RangeDetail(TypedDict):
|
||||||
|
Loading…
Reference in New Issue
Block a user