mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
style: allow python style check in tools
[no changelog]
This commit is contained in:
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
|
||||
import click
|
||||
from mako.template import Template
|
||||
from munch import munchify, Munch
|
||||
from munch import Munch, munchify
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
ROOT = HERE.parent.resolve()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
@@ -40,7 +40,7 @@ def bump_python(filename, new_version):
|
||||
|
||||
|
||||
def hex_lit(version):
|
||||
return r'"\x{:02X}"'.format(int(version))
|
||||
return rf'"\x{int(version):02X}"'
|
||||
|
||||
|
||||
@click.command()
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Iterator
|
||||
|
||||
import click
|
||||
|
||||
from typing import Iterator
|
||||
|
||||
LINK_RE = re.compile(r"\[#(\d+)\]")
|
||||
ISSUE_URL = "https://github.com/trezor/trezor-firmware/pull/{issue}"
|
||||
|
||||
@@ -265,7 +264,7 @@ def generate(project, version, date, check, only_models):
|
||||
|
||||
if only_models:
|
||||
generate_filtered(project, changelog)
|
||||
return 0
|
||||
return
|
||||
|
||||
args = ["towncrier", "build", "--yes", "--version", version, "--date", date]
|
||||
if check:
|
||||
|
||||
@@ -19,7 +19,7 @@ elif len(sys.argv) == 2:
|
||||
filenames = (FILE_T1, FILE_T2)
|
||||
else:
|
||||
print(f"Usage: {sys.argv[0]} HEX_CHALLENGE [FILE]...")
|
||||
print(f" HEX_CHALLENGE: a 0-32 byte challenge in hexadecimal")
|
||||
print(" HEX_CHALLENGE: a 0-32 byte challenge in hexadecimal")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ Taken from https://gist.github.com/patrickfuller/e2ea8a94badc5b6967ef3ca0a9452a
|
||||
|
||||
Currently writes all issues that have some Weight.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import requests
|
||||
import os.path
|
||||
|
||||
import requests
|
||||
|
||||
token = None
|
||||
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
@@ -49,7 +51,6 @@ def write_issues(r, csvout):
|
||||
if not weight:
|
||||
continue
|
||||
labels = ", ".join(labels)
|
||||
date = issue["created_at"].split("T")[0]
|
||||
milestone = issue["milestone"]["title"] if issue["milestone"] else ""
|
||||
assignee = issue["assignee"]["login"] if issue["assignee"] else ""
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
from elftools.construct import Struct, ULInt32, GreedyRange
|
||||
from elftools.common.construct_utils import ULEB128
|
||||
from elftools.construct import GreedyRange, Struct, ULInt32
|
||||
from elftools.elf.elffile import ELFFile
|
||||
|
||||
SYMBOL_TYPES = ("t", "w") # text, weak
|
||||
|
||||
@@ -49,13 +49,13 @@ from pathlib import Path
|
||||
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
|
||||
|
||||
import click
|
||||
from typing_extensions import ( # for python37 support, is not present in typing there
|
||||
Final,
|
||||
TypedDict,
|
||||
)
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
LineIgnores = List["LineIgnore"]
|
||||
|
||||
@@ -542,7 +542,7 @@ class PyrightTool:
|
||||
ignore_statements = self.get_ignore_statements(line)
|
||||
if not ignore_statements:
|
||||
self.inconsistencies.append(
|
||||
f"There is an empty `{self.IGNORE_PATTERN}` in {file}:{index+1}"
|
||||
f"There is an empty `{self.IGNORE_PATTERN}` in {file}:{index + 1}"
|
||||
)
|
||||
else:
|
||||
ignores.append(LineIgnore(index, ignore_statements))
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
from __future__ import annotations
|
||||
|
||||
import click
|
||||
import requests
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
import requests
|
||||
|
||||
from trezorlib import definitions, merkle_tree
|
||||
|
||||
ZIP_FILENAME = "definitions-sparse.zip"
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Literal
|
||||
from typing import Tuple
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
Bit = Literal[0, 1]
|
||||
Point = Tuple[int, int]
|
||||
|
||||
@@ -68,11 +68,10 @@ def check_usage_of_functions(func_mapping: Dict[str, List[str]]) -> None:
|
||||
is_used_mappings[func_name] = {"mapping": mapping, "is_used": False}
|
||||
|
||||
# Check if any of the mapping names is used - and mark it as used if so
|
||||
for func_name in is_used_mappings:
|
||||
for mapping in is_used_mappings[func_name]["mapping"]:
|
||||
is_there = _is_used(mapping)
|
||||
if is_there:
|
||||
is_used_mappings[func_name]["is_used"] = True
|
||||
for func_name, info in is_used_mappings.items():
|
||||
for m in info["mapping"]:
|
||||
if _is_used(m):
|
||||
info["is_used"] = True
|
||||
break
|
||||
|
||||
# Find unused functions and generate a report
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from pyasn1.codec.der.encoder import encode
|
||||
from pyasn1.codec.der.decoder import decode
|
||||
from pyasn1.type.univ import BitString
|
||||
from pyasn1_modules import rfc2459
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
from pyasn1.codec.der.decoder import decode
|
||||
from pyasn1.codec.der.encoder import encode
|
||||
from pyasn1.type.univ import BitString
|
||||
from pyasn1_modules import rfc2459
|
||||
|
||||
|
||||
def load_certificate(data: bytes):
|
||||
|
||||
@@ -37,6 +37,7 @@ Usage:
|
||||
- specifying FILES_TO_MODIFY
|
||||
- call the script with possible flags - see `python unify_test_files.py --help`
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -92,7 +93,7 @@ class FileUnifier:
|
||||
else:
|
||||
self.translations = {}
|
||||
print(
|
||||
f"{len(self.translations)} translations available (path/address and address/path)\n{80*'*'}"
|
||||
f"{len(self.translations)} translations available (path/address and address/path)\n{80 * '*'}"
|
||||
)
|
||||
|
||||
# For statistical purposes
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
^legacy/firmware/protob/options_pb2\.py
|
||||
^legacy/firmware/protob/messages_nem_pb2\.py
|
||||
^legacy/vendor
|
||||
^tools/automatic_battery_tester/.venv/
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
^core/src/
|
||||
^core/site_scons/
|
||||
^core/tests/
|
||||
^core/tools/
|
||||
^crypto/
|
||||
^legacy/
|
||||
^storage/
|
||||
^tools/
|
||||
^tests/
|
||||
^ci/
|
||||
|
||||
2
tools/style.py.typecheck.exclude
Normal file
2
tools/style.py.typecheck.exclude
Normal file
@@ -0,0 +1,2 @@
|
||||
^core/tools/
|
||||
^tools/
|
||||
Reference in New Issue
Block a user