mirror of
https://github.com/espressif/esptool.git
synced 2025-10-18 00:32:43 +08:00
fix: fix type annotation to comply with mypy
This commit is contained in:
@@ -12,6 +12,7 @@ from bitstring import BitArray, BitStream, CreationError
|
||||
import esptool
|
||||
|
||||
from . import util
|
||||
from typing import List
|
||||
|
||||
|
||||
class CheckArgValue(object):
|
||||
@@ -441,8 +442,8 @@ class EspEfusesBase(object):
|
||||
"""
|
||||
|
||||
_esp = None
|
||||
blocks = []
|
||||
efuses = []
|
||||
blocks: List[EfuseBlockBase] = []
|
||||
efuses: List = []
|
||||
coding_scheme = None
|
||||
force_write_always = None
|
||||
batch_mode_cnt = 0
|
||||
|
@@ -5,6 +5,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
import yaml
|
||||
|
||||
@@ -119,7 +120,7 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
self.CALC: List = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
dir_name, file_name = os.path.split(dir_name)
|
||||
|
@@ -9,6 +9,7 @@ import os
|
||||
import yaml
|
||||
|
||||
from ..mem_definition_base import EfuseBlocksBase, EfuseFieldsBase, EfuseRegistersBase
|
||||
from typing import List
|
||||
|
||||
|
||||
class EfuseDefineRegisters(EfuseRegistersBase):
|
||||
@@ -115,7 +116,7 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
self.CALC: List = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
dir_name, file_name = os.path.split(dir_name)
|
||||
|
@@ -13,6 +13,7 @@ from ..mem_definition_base import (
|
||||
EfuseFieldsBase,
|
||||
EfuseRegistersBase,
|
||||
)
|
||||
from typing import List
|
||||
|
||||
|
||||
class EfuseDefineRegisters(EfuseRegistersBase):
|
||||
@@ -119,7 +120,7 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
self.CALC: List = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
dir_name, file_name = os.path.split(dir_name)
|
||||
|
@@ -5,6 +5,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
from collections import namedtuple
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class EfuseRegistersBase(object):
|
||||
@@ -19,9 +20,9 @@ class EfuseRegistersBase(object):
|
||||
|
||||
|
||||
class EfuseBlocksBase(object):
|
||||
BLOCKS = None
|
||||
BLOCKS: Optional[List] = None
|
||||
NamedtupleBlock = namedtuple(
|
||||
"Block",
|
||||
"NamedtupleBlock",
|
||||
"name alias id rd_addr wr_addr write_disable_bit "
|
||||
"read_disable_bit len key_purpose",
|
||||
)
|
||||
@@ -49,7 +50,7 @@ class Field:
|
||||
word = None
|
||||
pos = None
|
||||
bit_len = 0
|
||||
alt_names = []
|
||||
alt_names: List[str] = []
|
||||
type = ""
|
||||
write_disable_bit = None
|
||||
read_disable_bit = None
|
||||
@@ -61,7 +62,7 @@ class Field:
|
||||
|
||||
class EfuseFieldsBase(object):
|
||||
def __init__(self, e_desc) -> None:
|
||||
self.ALL_EFUSES = []
|
||||
self.ALL_EFUSES: List = []
|
||||
|
||||
def set_category_and_class_type(efuse, name):
|
||||
def includes(name, names):
|
||||
|
@@ -11,7 +11,7 @@ import os
|
||||
import re
|
||||
import struct
|
||||
import tempfile
|
||||
from typing import BinaryIO, Optional
|
||||
from typing import IO, Optional
|
||||
|
||||
from intelhex import HexRecordError, IntelHex
|
||||
|
||||
@@ -43,7 +43,7 @@ def align_file_position(f, size):
|
||||
f.seek(align, 1)
|
||||
|
||||
|
||||
def intel_hex_to_bin(file: BinaryIO, start_addr: Optional[int] = None) -> BinaryIO:
|
||||
def intel_hex_to_bin(file: IO[bytes], start_addr: Optional[int] = None) -> IO[bytes]:
|
||||
"""Convert IntelHex file to temp binary file with padding from start_addr
|
||||
If hex file was detected return temp bin file object; input file otherwise"""
|
||||
INTEL_HEX_MAGIC = b":"
|
||||
|
@@ -13,6 +13,8 @@ import string
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
|
||||
from .config import load_config_file
|
||||
from .reset import (
|
||||
@@ -59,7 +61,7 @@ except ImportError:
|
||||
print(
|
||||
"The installed version (%s) of pyserial appears to be too old for esptool.py "
|
||||
"(Python interpreter %s). Check the README for installation instructions."
|
||||
% (sys.VERSION, sys.executable)
|
||||
% (serial.VERSION, sys.executable)
|
||||
)
|
||||
raise
|
||||
except Exception:
|
||||
@@ -185,6 +187,8 @@ class ESPLoader(object):
|
||||
|
||||
CHIP_NAME = "Espressif device"
|
||||
IS_STUB = False
|
||||
STUB_CLASS: Optional[object] = None
|
||||
BOOTLOADER_IMAGE: Optional[object] = None
|
||||
|
||||
DEFAULT_PORT = "/dev/ttyUSB0"
|
||||
|
||||
|
@@ -8,6 +8,8 @@ import struct
|
||||
from .esp32c3 import ESP32C3ROM
|
||||
from ..util import FatalError, NotImplementedInROMError
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
class ESP32H2BETA1ROM(ESP32C3ROM):
|
||||
CHIP_NAME = "ESP32-H2(beta1)"
|
||||
@@ -66,7 +68,7 @@ class ESP32H2BETA1ROM(ESP32C3ROM):
|
||||
|
||||
FLASH_ENCRYPTED_WRITE_ALIGN = 16
|
||||
|
||||
MEMORY_MAP = []
|
||||
MEMORY_MAP: List = []
|
||||
|
||||
FLASH_FREQUENCY = {
|
||||
"48m": 0xF,
|
||||
|
Reference in New Issue
Block a user