From 7d53e338895624f905f91f4e64fa94c0f8afaa6c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 Feb 2025 10:21:27 +1100 Subject: [PATCH] Cleanup: use typed named tuple for code_clean.py --- tools/utils_maintenance/code_clean.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index 3caf0790827..77f8d0d9e94 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -24,6 +24,7 @@ import string from typing import ( Any, + NamedTuple, ) from collections.abc import ( Iterator, @@ -406,25 +407,14 @@ def find_build_args_make(build_dir: str) -> ProcessedCommands | None: # # Although this seems like it's not a common use-case. -from collections import namedtuple -Edit = namedtuple( - "Edit", ( - # Keep first, for sorting. - "span", - "content", - "content_fail", +class Edit(NamedTuple): + span: tuple[int, int] + content: str + content_fail: str - # Optional. - "extra_build_args", - ), - - defaults=( - # `extra_build_args`. - None, - ) -) -del namedtuple + # Optional. + extra_build_args: tuple[str, ...] | None = None class EditGenerator: