From 7729e80fdddbd9f75cb350de70a84ed26cb601fd Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 22 Jul 2025 22:58:52 +1000 Subject: [PATCH] all: Go back to using default ruff quote style. Commit dc2fcfcc5511a371ff684f7d7772e7a7b479246d seems to have accidentally changed the ruff quote style to "preserve", instead of keeping it at the default which is "double". Put it back to the default and update relevant .py files with this rule. Signed-off-by: Damien George --- pyproject.toml | 1 - tests/cpydiff/core_fstring_parser.py | 4 +-- tests/extmod/deflate_compress_memory_error.py | 2 +- tests/extmod/json_loads.py | 2 +- tests/extmod/json_loads_int_64.py | 2 +- tests/extmod/tls_dtls.py | 2 +- tests/float/math_fun_special.py | 2 +- tests/import/import_star.py | 32 +++++++++---------- tests/import/pkgstar_all_array/__init__.py | 2 +- tests/import/pkgstar_all_miss/__init__.py | 2 +- tests/import/pkgstar_all_tuple/__init__.py | 2 +- tests/run-tests.py | 4 +-- tools/mpremote/mpremote/commands.py | 8 ++--- tools/mpremote/mpremote/main.py | 2 +- tools/mpremote/mpremote/repl.py | 2 +- tools/mpy_ld.py | 22 ++++++------- 16 files changed, 45 insertions(+), 46 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0dd15d06c7..8c14c2bffa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,4 +68,3 @@ mccabe.max-complexity = 40 # repl_: not real python files # viper_args: uses f(*) exclude = ["tests/basics/*.py", "tests/*/repl_*.py", "tests/micropython/viper_args.py"] -quote-style = "preserve" diff --git a/tests/cpydiff/core_fstring_parser.py b/tests/cpydiff/core_fstring_parser.py index 570b92434a..04b24cdfb6 100644 --- a/tests/cpydiff/core_fstring_parser.py +++ b/tests/cpydiff/core_fstring_parser.py @@ -5,5 +5,5 @@ cause: MicroPython is optimised for code space. workaround: Always use balanced braces and brackets in expressions inside f-strings """ -print(f'{"hello { world"}') -print(f'{"hello ] world"}') +print(f"{'hello { world'}") +print(f"{'hello ] world'}") diff --git a/tests/extmod/deflate_compress_memory_error.py b/tests/extmod/deflate_compress_memory_error.py index 56ce060308..19bef87bff 100644 --- a/tests/extmod/deflate_compress_memory_error.py +++ b/tests/extmod/deflate_compress_memory_error.py @@ -28,7 +28,7 @@ l.pop() # Try to compress. This will try to allocate a large window and fail. try: - g.write('test') + g.write("test") except MemoryError: print("MemoryError") diff --git a/tests/extmod/json_loads.py b/tests/extmod/json_loads.py index 095e67d740..092402d715 100644 --- a/tests/extmod/json_loads.py +++ b/tests/extmod/json_loads.py @@ -86,7 +86,7 @@ except ValueError: # incomplete array declaration try: - my_print(json.loads('[0,')) + my_print(json.loads("[0,")) except ValueError: print("ValueError") diff --git a/tests/extmod/json_loads_int_64.py b/tests/extmod/json_loads_int_64.py index 193a3c28d8..f6236f1904 100644 --- a/tests/extmod/json_loads_int_64.py +++ b/tests/extmod/json_loads_int_64.py @@ -13,4 +13,4 @@ print(json.loads("9111222333444555666")) print(json.loads("-9111222333444555666")) print(json.loads("9111222333444555666")) print(json.loads("-9111222333444555666")) -print(json.loads("[\"9111222333444555666777\",9111222333444555666]")) +print(json.loads('["9111222333444555666777",9111222333444555666]')) diff --git a/tests/extmod/tls_dtls.py b/tests/extmod/tls_dtls.py index a475cce8c1..753ab2fee4 100644 --- a/tests/extmod/tls_dtls.py +++ b/tests/extmod/tls_dtls.py @@ -35,7 +35,7 @@ client_socket = DummySocket() dtls_server_ctx = SSLContext(PROTOCOL_DTLS_SERVER) dtls_server_ctx.verify_mode = CERT_NONE dtls_server = dtls_server_ctx.wrap_socket( - server_socket, do_handshake_on_connect=False, client_id=b'dummy_client_id' + server_socket, do_handshake_on_connect=False, client_id=b"dummy_client_id" ) print("Wrapped DTLS Server") diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py index a747f73e9f..ecacedec55 100644 --- a/tests/float/math_fun_special.py +++ b/tests/float/math_fun_special.py @@ -52,6 +52,6 @@ for function_name, function, test_vals in functions: except ValueError as e: ans = str(e) # a tiny error in REPR_C value for 1.5204998778 causes a wrong rounded value - if is_REPR_C and function_name == 'erfc' and ans == "1.521": + if is_REPR_C and function_name == "erfc" and ans == "1.521": ans = "1.52" print("{}({:.4g}) = {}".format(function_name, value, ans)) diff --git a/tests/import/import_star.py b/tests/import/import_star.py index 0947f6a835..2cb21b877d 100644 --- a/tests/import/import_star.py +++ b/tests/import/import_star.py @@ -7,39 +7,39 @@ try: except TypeError: # 2-argument version of next() not supported # we are probably not at MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES - print('SKIP') + print("SKIP") raise SystemExit # 1. test default visibility from pkgstar_default import * -print('visibleFun' in globals()) -print('VisibleClass' in globals()) -print('_hiddenFun' in globals()) -print('_HiddenClass' in globals()) +print("visibleFun" in globals()) +print("VisibleClass" in globals()) +print("_hiddenFun" in globals()) +print("_HiddenClass" in globals()) print(visibleFun()) # 2. test explicit visibility as defined by __all__ (as an array) from pkgstar_all_array import * -print('publicFun' in globals()) -print('PublicClass' in globals()) -print('unlistedFun' in globals()) -print('UnlistedClass' in globals()) -print('_privateFun' in globals()) -print('_PrivateClass' in globals()) +print("publicFun" in globals()) +print("PublicClass" in globals()) +print("unlistedFun" in globals()) +print("UnlistedClass" in globals()) +print("_privateFun" in globals()) +print("_PrivateClass" in globals()) print(publicFun()) # test dynamic import as used in asyncio -print('dynamicFun' in globals()) +print("dynamicFun" in globals()) print(dynamicFun()) # 3. test explicit visibility as defined by __all__ (as an tuple) from pkgstar_all_tuple import * -print('publicFun2' in globals()) -print('PublicClass2' in globals()) -print('unlistedFun2' in globals()) -print('UnlistedClass2' in globals()) +print("publicFun2" in globals()) +print("PublicClass2" in globals()) +print("unlistedFun2" in globals()) +print("UnlistedClass2" in globals()) print(publicFun2()) # 4. test reporting of missing entries in __all__ diff --git a/tests/import/pkgstar_all_array/__init__.py b/tests/import/pkgstar_all_array/__init__.py index 4499a94d59..03b012123f 100644 --- a/tests/import/pkgstar_all_array/__init__.py +++ b/tests/import/pkgstar_all_array/__init__.py @@ -1,4 +1,4 @@ -__all__ = ['publicFun', 'PublicClass', 'dynamicFun'] +__all__ = ["publicFun", "PublicClass", "dynamicFun"] # Definitions below should always be imported by a star import diff --git a/tests/import/pkgstar_all_miss/__init__.py b/tests/import/pkgstar_all_miss/__init__.py index d960c7d0e2..f9bbb53807 100644 --- a/tests/import/pkgstar_all_miss/__init__.py +++ b/tests/import/pkgstar_all_miss/__init__.py @@ -1,4 +1,4 @@ -__all__ = ('existingFun', 'missingFun') +__all__ = ("existingFun", "missingFun") def existingFun(): diff --git a/tests/import/pkgstar_all_tuple/__init__.py b/tests/import/pkgstar_all_tuple/__init__.py index a97715ed39..433ddc8e97 100644 --- a/tests/import/pkgstar_all_tuple/__init__.py +++ b/tests/import/pkgstar_all_tuple/__init__.py @@ -1,4 +1,4 @@ -__all__ = ('publicFun2', 'PublicClass2') +__all__ = ("publicFun2", "PublicClass2") # Definitions below should always be imported by a star import diff --git a/tests/run-tests.py b/tests/run-tests.py index 328d69f633..a428665db0 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -16,7 +16,7 @@ import threading import tempfile # Maximum time to run a single test, in seconds. -TEST_TIMEOUT = float(os.environ.get('MICROPY_TEST_TIMEOUT', 30)) +TEST_TIMEOUT = float(os.environ.get("MICROPY_TEST_TIMEOUT", 30)) # See stackoverflow.com/questions/2632199: __file__ nor sys.argv[0] # are guaranteed to always work, this one should though. @@ -411,7 +411,7 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): def send_get(what): # Detect {\x00} pattern and convert to ctrl-key codes. ctrl_code = lambda m: bytes([int(m.group(1))]) - what = re.sub(rb'{\\x(\d\d)}', ctrl_code, what) + what = re.sub(rb"{\\x(\d\d)}", ctrl_code, what) os.write(master, what) return get() diff --git a/tools/mpremote/mpremote/commands.py b/tools/mpremote/mpremote/commands.py index 428600baf4..4974c71e2e 100644 --- a/tools/mpremote/mpremote/commands.py +++ b/tools/mpremote/mpremote/commands.py @@ -309,7 +309,7 @@ def do_filesystem_recursive_rm(state, path, args): os.path.join(r_cwd, path) if not os.path.isabs(path) else path ) if isinstance(state.transport, SerialTransport) and abs_path.startswith( - f'{SerialTransport.fs_hook_mount}/' + f"{SerialTransport.fs_hook_mount}/" ): raise CommandError( f"rm -r not permitted on {SerialTransport.fs_hook_mount} directory" @@ -335,11 +335,11 @@ def do_filesystem_recursive_rm(state, path, args): def human_size(size, decimals=1): - for unit in ['B', 'K', 'M', 'G', 'T']: - if size < 1024.0 or unit == 'T': + for unit in ["B", "K", "M", "G", "T"]: + if size < 1024.0 or unit == "T": break size /= 1024.0 - return f"{size:.{decimals}f}{unit}" if unit != 'B' else f"{int(size)}" + return f"{size:.{decimals}f}{unit}" if unit != "B" else f"{int(size)}" def do_filesystem_tree(state, path, args): diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index 0441857fab..0aec1efad1 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -598,7 +598,7 @@ def main(): cmd == "fs" and len(command_args) >= 1 and command_args[0] in ("ls", "tree") - and sum(1 for a in command_args if not a.startswith('-')) == 1 + and sum(1 for a in command_args if not a.startswith("-")) == 1 ): command_args.append("") diff --git a/tools/mpremote/mpremote/repl.py b/tools/mpremote/mpremote/repl.py index 4fda04a2e2..ad7e83ea8b 100644 --- a/tools/mpremote/mpremote/repl.py +++ b/tools/mpremote/mpremote/repl.py @@ -110,7 +110,7 @@ def _is_disconnect_exception(exception): False otherwise. """ if isinstance(exception, OSError): - if hasattr(exception, 'args') and len(exception.args) > 0: + if hasattr(exception, "args") and len(exception.args) > 0: # IO error, device disappeared if exception.args[0] == 5: return True diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py index a600ec12c3..af8450a842 100755 --- a/tools/mpy_ld.py +++ b/tools/mpy_ld.py @@ -1521,31 +1521,31 @@ def parse_linkerscript(source): symbols = {} LINE_REGEX = re.compile( - r'^(?PPROVIDE\()?' # optional weak marker start - r'(?P[a-zA-Z_]\w*)' # symbol name - r'=0x(?P
[\da-fA-F]{1,8})*' # symbol address - r'(?(weak)\));$', # optional weak marker end and line terminator + r"^(?PPROVIDE\()?" # optional weak marker start + r"(?P[a-zA-Z_]\w*)" # symbol name + r"=0x(?P
[\da-fA-F]{1,8})*" # symbol address + r"(?(weak)\));$", # optional weak marker end and line terminator re.ASCII, ) inside_comment = False for line in (line.strip() for line in source.readlines()): - if line.startswith('/*') and not inside_comment: - if not line.endswith('*/'): + if line.startswith("/*") and not inside_comment: + if not line.endswith("*/"): inside_comment = True continue if inside_comment: - if line.endswith('*/'): + if line.endswith("*/"): inside_comment = False continue - if line.startswith('//'): + if line.startswith("//"): continue - match = LINE_REGEX.match(''.join(line.split())) + match = LINE_REGEX.match("".join(line.split())) if not match: continue tokens = match.groupdict() - symbol = tokens['symbol'] - address = int(tokens['address'], 16) + symbol = tokens["symbol"] + address = int(tokens["address"], 16) if symbol in symbols: raise ValueError(f"Symbol {symbol} already defined") symbols[symbol] = address