Skip to content

Commit

Permalink
[core] Upgrade black to v24.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Feb 26, 2024
1 parent fb50203 commit 5e076eb
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 29 deletions.
22 changes: 14 additions & 8 deletions ltchiptool/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,21 @@ def add_families(families: List[Family], level: int):
indent + family.description,
family.name,
family.code,
f"{family.short_name.upper()} / 0x{family.id:08X}"
if family.short_name and family.id
else "-",
(
f"{family.short_name.upper()} / 0x{family.id:08X}"
if family.short_name and family.id
else "-"
),
"-" if not family.id else "Yes" if family.is_supported else "No",
"-"
if not family.id
else "Yes"
if family.is_supported and family.has_arduino_core
else "No",
(
"-"
if not family.id
else (
"Yes"
if family.is_supported and family.has_arduino_core
else "No"
)
),
family.target_package or "-",
]
)
Expand Down
2 changes: 1 addition & 1 deletion ltchiptool/gui/panels/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def OnUpdate(self, target: wx.Window = None):
manual = False

match target:
case (self.Read | self.ReadROM | self.ReadEfuse) if self.file:
case self.Read | self.ReadROM | self.ReadEfuse if self.file:
# generate a new filename for reading, to prevent
# accidentally overwriting firmware files
self.generate_read_filename()
Expand Down
8 changes: 5 additions & 3 deletions ltchiptool/soc/ambz2/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ def elf2bin(self, input: str, ota_idx: int) -> List[FirmwareBinary]:
type=image.type,
# use FF to allow recalculating by OTA code
serial=0xFFFFFFFF if idx == 0 else 0,
user_keys=[FF_32, config.keys.user_keys[region]]
if idx == 0
else [FF_32, FF_32],
user_keys=(
[FF_32, config.keys.user_keys[region]]
if idx == 0
else [FF_32, FF_32]
),
),
data=Firmware(
sections=[
Expand Down
6 changes: 3 additions & 3 deletions ltchiptool/soc/ambz2/util/models/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def update(ctx: Context):

_0: ... = action(packing(update))
_hash: ... = checksum_start(
init=lambda ctx: HMAC(ctx.hash_key, digestmod=sha256)
if ctx.hash_key
else sha256(),
init=lambda ctx: (
HMAC(ctx.hash_key, digestmod=sha256) if ctx.hash_key else sha256()
),
update=lambda data, obj, ctx: obj.update(data),
end=lambda obj, ctx: obj.digest(),
)
Expand Down
4 changes: 3 additions & 1 deletion ltchiptool/soc/bk72xx/util/rbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class RBL:
version: Union[str, bytes] = "1.00"
sn: Union[str, bytes] = "0" * 23
data_crc: int = 0
data_hash: int = 0x811C9DC5 # https://github.com/znerol/py-fnvhash/blob/master/fnvhash/__init__.py
data_hash: int = (
0x811C9DC5 # https://github.com/znerol/py-fnvhash/blob/master/fnvhash/__init__.py
)
raw_size: int = 0
data_size: int = 0
container_size: int = 0
Expand Down
6 changes: 2 additions & 4 deletions ltchiptool/util/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@


class CryptoAES:
def encrypt(self, data: bytes) -> bytes:
...
def encrypt(self, data: bytes) -> bytes: ...

def decrypt(self, data: bytes) -> bytes:
...
def decrypt(self, data: bytes) -> bytes: ...


def make_aes_crypto(key: bytes, iv: bytes) -> CryptoAES:
Expand Down
8 changes: 5 additions & 3 deletions ltchiptool/util/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def make(
return Detection(
name="",
size=0,
type=Detection.Type.VALID
if offset is not None
else Detection.Type.VALID_NEED_OFFSET,
type=(
Detection.Type.VALID
if offset is not None
else Detection.Type.VALID_NEED_OFFSET
),
file_type=type_name,
offset=offset or 0,
skip=skip,
Expand Down
6 changes: 1 addition & 5 deletions ltctplugin/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ def type_text(self) -> str:
return (
"CLI + GUI"
if self.has_cli and self.has_gui
else "CLI"
if self.has_cli
else "GUI"
if self.has_gui
else "?"
else "CLI" if self.has_cli else "GUI" if self.has_gui else "?"
)

@property
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ markers = "platform_machine in 'armv6l,armv7l,armv8l,armv8b,aarch64'"
gui = ["wxPython", "pywin32", "zeroconf", "pyuac", "pylnk3"]

[tool.poetry.dev-dependencies]
black = "^22.6.0"
black = "^24.1.0"
isort = "^5.10.1"
autoflake = "^1.4"

Expand Down

0 comments on commit 5e076eb

Please sign in to comment.