all: Fix various Python coding inconsistencies found by ruff.
This fixes: - type-comparison (E721): do not compare types, use isinstance(). - string-dot-format-missing-arguments (F524): .format call is missing argument(s) for placeholder(s): {message}. - f-string-missing-placeholders (F541). - is-literal (F632): Use != to compare constant literals. The last one is fixed by just comparing for truthfulness of `state`.
This commit is contained in:
parent
8f8bd98164
commit
79e57473b2
|
@ -123,7 +123,7 @@ def gather(*aws, return_exceptions=False):
|
||||||
|
|
||||||
# Either this gather was cancelled, or one of the sub-tasks raised an exception with
|
# Either this gather was cancelled, or one of the sub-tasks raised an exception with
|
||||||
# return_exceptions==False, so reraise the exception here.
|
# return_exceptions==False, so reraise the exception here.
|
||||||
if state is not 0:
|
if state:
|
||||||
raise state
|
raise state
|
||||||
|
|
||||||
# Return the list of return values of each sub-task.
|
# Return the list of return values of each sub-task.
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Pins:
|
||||||
continue
|
continue
|
||||||
if not row[pin_col].isdigit():
|
if not row[pin_col].isdigit():
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Invalid pin number {:s} in row {:s}".format(row[pin_col]), row
|
"Invalid pin number {:s} in row {:s}".format(row[pin_col], row)
|
||||||
)
|
)
|
||||||
# Pin numbers must start from 0 when used with the TI API
|
# Pin numbers must start from 0 when used with the TI API
|
||||||
pin_num = int(row[pin_col]) - 1
|
pin_num = int(row[pin_col]) - 1
|
||||||
|
|
|
@ -704,7 +704,7 @@ def check_for_updates(force=False):
|
||||||
if fus_uptodate and ws_uptodate and not force:
|
if fus_uptodate and ws_uptodate and not force:
|
||||||
log(f"Already up to date: fus: {current_version_fus}, ws: {current_version_ws}")
|
log(f"Already up to date: fus: {current_version_fus}, ws: {current_version_ws}")
|
||||||
else:
|
else:
|
||||||
log(f"Starting firmware update")
|
log("Starting firmware update")
|
||||||
log(f" - fus: {current_version_fus} -> {vers_fus}")
|
log(f" - fus: {current_version_fus} -> {vers_fus}")
|
||||||
log(f" - ws: {current_version_ws} -> {vers_ws}")
|
log(f" - ws: {current_version_ws} -> {vers_ws}")
|
||||||
_write_state(_STATE_WAITING_FOR_FUS)
|
_write_state(_STATE_WAITING_FOR_FUS)
|
||||||
|
|
|
@ -36,7 +36,7 @@ def create_c_from_file(c_filename, zip_filename):
|
||||||
break
|
break
|
||||||
print(' ', end='', file=c_file)
|
print(' ', end='', file=c_file)
|
||||||
for byte in buf:
|
for byte in buf:
|
||||||
if type(byte) is types.StringType:
|
if isinstance(byte, types.StringType):
|
||||||
print(' 0x{:02x},'.format(ord(byte)), end='', file=c_file)
|
print(' 0x{:02x},'.format(ord(byte)), end='', file=c_file)
|
||||||
else:
|
else:
|
||||||
print(' 0x{:02x},'.format(byte), end='', file=c_file)
|
print(' 0x{:02x},'.format(byte), end='', file=c_file)
|
||||||
|
|
Loading…
Reference in New Issue