From nobody Sat Nov 15 17:43:59 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749762182; cv=none; d=zohomail.com; s=zohoarc; b=fCxnKyFu+1F2lHzon+ggNeQ5c/MSdLGedx86dHtkrPDZAfeQnkPy9dVQE3hj5VOhvmWm47ssYW5VOlwe+LjPr2FUWWmg/rYTVj9OiwyhuKh6oTujT6E1hzN/Wjz9o+iqQu52OiVjsVlT8ulqj++NhEAnjY+O3saXW8sfMf8AQSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749762182; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JJA305OgYfWdFpeBb895vZC1w+JpOwGtBxhuAxXTPBY=; b=fZspdEyMWvu6kCAQte5ArkjPFO90qGVYOm4qYVVnfD8V+xV109z+7tkLcGRIM/PQg7UKXAehSTcrlxJpI8k6xfdnxtcy8FP39dxHRIyWyFGq6KurU8XPw5pKaEfEIRHpuvWQFmbSS9Z/rtCqgkbdckqezGkcPwUmG/BJoGQhO6U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749762182714824.6306320305805; Thu, 12 Jun 2025 14:03:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uPp4F-0007Q4-DB; Thu, 12 Jun 2025 17:02:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uPp3u-00070H-4z for qemu-devel@nongnu.org; Thu, 12 Jun 2025 17:02:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uPp3r-0001OQ-Me for qemu-devel@nongnu.org; Thu, 12 Jun 2025 17:02:13 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-510-906kJsTJPgW6XmaniTmVEQ-1; Thu, 12 Jun 2025 17:02:04 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DED151956096; Thu, 12 Jun 2025 21:01:58 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A929F1956050; Thu, 12 Jun 2025 21:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749762130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JJA305OgYfWdFpeBb895vZC1w+JpOwGtBxhuAxXTPBY=; b=iIM77MN3LTvQBQck3WD/ewUNLbr83nkn+zG3eyG0Qgl5ZfDvc36XHXAb5iQu7lT1F6BAzQ KE0gJ9rhkz0QwuI8ZLPhphCj4BALco6WLD3ipUscc/SCNWAozfHCUrxXRH69haM47qHCG5 WqjLhLS3FpQkdnR8PQd3dKahbZS5ZSY= X-MC-Unique: 906kJsTJPgW6XmaniTmVEQ-1 X-Mimecast-MFC-AGG-ID: 906kJsTJPgW6XmaniTmVEQ_1749762119 From: John Snow To: qemu-devel@nongnu.org Cc: Joel Stanley , Yi Liu , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Helge Deller , Marcel Apfelbaum , Andrew Jeffery , Fabiano Rosas , Alexander Bulekov , Darren Kenny , Leif Lindholm , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Ed Maste , Gerd Hoffmann , Warner Losh , Kevin Wolf , Tyrone Ting , Eric Blake , Palmer Dabbelt , Yoshinori Sato , Troy Lee , Halil Pasic , Akihiko Odaki , Michael Roth , Laurent Vivier , Ani Sinha , Weiwei Li , John Snow , Eric Farman , Steven Lee , Brian Cain , Li-Wen Hsu , Jamin Lin , qemu-s390x@nongnu.org, Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Bernhard Beschow , =?UTF-8?q?Cl=C3=A9ment=20Mathieu--Drif?= , Maksim Davydov , Niek Linnenbank , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Christian Borntraeger , Paul Durrant , Manos Pitsidianakis , Jagannathan Raman , Igor Mitsyanko , Max Filippov , Markus Armbruster , Pierrick Bouvier , "Michael S. Tsirkin" , Anton Johansson , Peter Maydell , Cleber Rosa , Eric Auger , Yanan Wang , qemu-arm@nongnu.org, Hao Wu , Mads Ynddal , Sriram Yagnaraman , qemu-riscv@nongnu.org, Paolo Bonzini , Jason Wang , Nicholas Piggin , Michael Rolnik , Zhao Liu , Alessandro Di Federico , Thomas Huth , Antony Pavlov , Jiaxun Yang , Hanna Reitz , Ilya Leoshkevich , Marcelo Tosatti , Nina Schoetterl-Glausch , Daniel Henrique Barboza , Qiuhao Li , Hyman Huang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Magnus Damm , qemu-rust@nongnu.org, Bandan Das , Strahinja Jankovic , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Fam Zheng , Jia Liu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alistair Francis , Subbaraya Sundeep , Kyle Evans , Song Gao , Alexandre Iooss , Aurelien Jarno , Liu Zhiwei , Peter Xu , Stefan Hajnoczi , BALATON Zoltan , Elena Ufimtseva , "Edgar E. Iglesias" , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-ppc@nongnu.org, Radoslaw Biernacki , Beniamino Galvani , David Hildenbrand , Richard Henderson , David Woodhouse , Eduardo Habkost , Ahmed Karaman , Huacai Chen , Mahmoud Mandour , Harsh Prateek Bora Subject: [PATCH v2 12/12] scripts/codeconverter: remove * imports Date: Thu, 12 Jun 2025 16:54:50 -0400 Message-ID: <20250612205451.1177751-13-jsnow@redhat.com> In-Reply-To: <20250612205451.1177751-1-jsnow@redhat.com> References: <20250612205451.1177751-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749762184663116600 Content-Type: text/plain; charset="utf-8" Python static analysis tools generally don't like dealing with asterisk imports as it's tough to deduce what's actually getting used and from where. Replace these imports with explicit imports. This also helps eliminate deprecated imports from the typing module. These files have more style issues that are not addressed by this patch, so the command-line I am using to ensure I am not creating new identifier problems is a flake8 command set to squelch most style issues: flake8 --ignore=3DE111,E114,E117,E127,E128,E129,E201,E221,E222,\ E225,E226,E252,E231,E261,E265,E301,E302,E303,\ E305,E306,E501,E502,E703,E712,E731,E741,F841,\ W292,W391,W503,W504 \ *.py I am also using pylint's errors-only mode: pylint -E *.py Signed-off-by: John Snow --- .../codeconverter/codeconverter/patching.py | 4 +- .../codeconverter/codeconverter/qom_macros.py | 83 +++++++++++++------ .../codeconverter/qom_type_info.py | 76 ++++++++++++++--- .../codeconverter/test_patching.py | 9 +- .../codeconverter/test_regexps.py | 32 ++++++- scripts/codeconverter/codeconverter/utils.py | 7 +- 6 files changed, 161 insertions(+), 50 deletions(-) diff --git a/scripts/codeconverter/codeconverter/patching.py b/scripts/code= converter/codeconverter/patching.py index 0165085caed..f336377972e 100644 --- a/scripts/codeconverter/codeconverter/patching.py +++ b/scripts/codeconverter/codeconverter/patching.py @@ -25,6 +25,8 @@ Union, ) =20 +from .utils import LineAndColumn, line_col + =20 logger =3D logging.getLogger(__name__) DBG =3D logger.debug @@ -32,8 +34,6 @@ WARN =3D logger.warning ERROR =3D logger.error =20 -from .utils import * - =20 T =3D TypeVar('T') =20 diff --git a/scripts/codeconverter/codeconverter/qom_macros.py b/scripts/co= deconverter/codeconverter/qom_macros.py index 04512bfffdd..f28d91ae90c 100644 --- a/scripts/codeconverter/codeconverter/qom_macros.py +++ b/scripts/codeconverter/codeconverter/qom_macros.py @@ -5,14 +5,47 @@ # # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. +from collections.abc import Iterable, Iterator from itertools import chain import logging import re -from typing import * +from typing import ( + Literal, + NamedTuple, + Optional, + cast, +) =20 -from .patching import * -from .regexps import * -from .utils import * +from .patching import ( + FileInfo, + FileList, + FileMatch, + Patch, + RequiredIdentifier, +) +from .regexps import ( + CPP_SPACE, + NAMED, + OPTIONAL_PARS, + OR, + RE_COMMENT, + RE_COMMENTS, + RE_EXPRESSION, + RE_FILE_BEGIN, + RE_FUN_CALL, + RE_IDENTIFIER, + RE_INCLUDE, + RE_MACRO_CONCAT, + RE_NUMBER, + RE_SIMPLEDEFINE, + RE_STRING, + RE_STRUCT_TYPE, + RE_TYPE, + SP, + M, + S, +) +from .utils import merge, opt_compare =20 =20 logger =3D logging.getLogger(__name__) @@ -69,7 +102,7 @@ def __str__(self) -> str: s =3D ', '.join('%s=3D%s' % (f,v) for f,v in values if v is not No= ne) return f'{s}' =20 - def check_consistency(self) -> List[str]: + def check_consistency(self) -> list[str]: """Check if identifiers are consistent with each other, return list of problems (or empty list if everything seems consist= ent) """ @@ -236,7 +269,7 @@ def find_typedef(f: FileInfo, name: Optional[str]) -> O= ptional[TypedefMatch]: NAMED('qom_typename', RE_IDENTIFIER), r'\s*\)\n', n=3D'?', name=3D'check_args')) =20 -EXPECTED_CHECKER_SUFFIXES: List[Tuple[CheckerMacroName, str]] =3D [ +EXPECTED_CHECKER_SUFFIXES: list[tuple[CheckerMacroName, str]] =3D [ ('OBJECT_GET_CLASS', '_GET_CLASS'), ('OBJECT_CLASS_CHECK', '_CLASS'), ] @@ -268,7 +301,7 @@ def sanity_check(self) -> None: if self.typedefname and self.find_typedef() is None: self.warn("typedef used by %s not found", self.name) =20 - def find_matching_macros(self) -> List['TypeCheckMacro']: + def find_matching_macros(self) -> list['TypeCheckMacro']: """Find other check macros that generate the same macro names =20 The returned list will always be sorted. @@ -281,7 +314,7 @@ def find_matching_macros(self) -> List['TypeCheckMacro'= ]: and (my_ids.uppercase =3D=3D m.type_identifiers.upperca= se or my_ids.typename =3D=3D m.type_identifiers.typen= ame)] =20 - def merge_ids(self, matches: List['TypeCheckMacro']) -> Optional[TypeI= dentifiers]: + def merge_ids(self, matches: list['TypeCheckMacro']) -> Optional[TypeI= dentifiers]: """Try to merge info about type identifiers from all matches in a = list""" if not matches: return None @@ -581,10 +614,12 @@ def gen_patches(self) -> Iterable[Patch]: return =20 # group checkers by uppercase name: - decl_types: List[Type[TypeDeclaration]] =3D [DeclareInstanceChecke= r, DeclareInstanceType, - DeclareClassCheckers, D= eclareClassType, - DeclareObjCheckers] - checker_dict: Dict[str, List[TypeDeclaration]] =3D {} + decl_types: list[type[TypeDeclaration]] =3D [ + DeclareInstanceChecker, DeclareInstanceType, + DeclareClassCheckers, DeclareClassType, + DeclareObjCheckers + ] + checker_dict: dict[str, list[TypeDeclaration]] =3D {} for t in decl_types: for m in self.file.matches_of_type(t): checker_dict.setdefault(m.group('uppercase'), []).append(m) @@ -603,9 +638,9 @@ def gen_patches(self) -> Iterable[Patch]: field_dict =3D {f: v.pop() if v else None for f,v in fvalues.i= tems()} yield from self.gen_patches_for_type(uppercase, checkers, fiel= d_dict) =20 - def find_conflicts(self, uppercase: str, checkers: List[TypeDeclaratio= n]) -> bool: + def find_conflicts(self, uppercase: str, checkers: list[TypeDeclaratio= n]) -> bool: """Look for conflicting declarations that would make it unsafe to = add new ones""" - conflicting: List[FileMatch] =3D [] + conflicting: list[FileMatch] =3D [] # conflicts in the same file: conflicting.extend(chain(self.file.find_matches(DefineDirective, u= ppercase), self.file.find_matches(DeclareInterfaceCh= ecker, uppercase, 'uppercase'), @@ -634,8 +669,8 @@ def find_conflicts(self, uppercase: str, checkers: List= [TypeDeclaration]) -> boo return False =20 def gen_patches_for_type(self, uppercase: str, - checkers: List[TypeDeclaration], - fields: Dict[str, Optional[str]]) -> Iterable= [Patch]: + checkers: list[TypeDeclaration], + fields: dict[str, Optional[str]]) -> Iterable= [Patch]: """Should be reimplemented by subclasses""" return yield @@ -644,8 +679,8 @@ class DeclareVoidTypes(TypeDeclarationFixup): """Add DECLARE_*_TYPE(..., void) when there's no declared type""" regexp =3D RE_FILE_BEGIN def gen_patches_for_type(self, uppercase: str, - checkers: List[TypeDeclaration], - fields: Dict[str, Optional[str]]) -> Iterable= [Patch]: + checkers: list[TypeDeclaration], + fields: dict[str, Optional[str]]) -> Iterable= [Patch]: if self.find_conflicts(uppercase, checkers): return =20 @@ -672,8 +707,8 @@ def gen_patches_for_type(self, uppercase: str, class AddDeclareTypeName(TypeDeclarationFixup): """Add DECLARE_TYPE_NAME declarations if necessary""" def gen_patches_for_type(self, uppercase: str, - checkers: List[TypeDeclaration], - fields: Dict[str, Optional[str]]) -> Iterable= [Patch]: + checkers: list[TypeDeclaration], + fields: dict[str, Optional[str]]) -> Iterable= [Patch]: typename =3D fields.get('typename') if typename is None: self.warn("typename unavailable") @@ -754,7 +789,7 @@ def find_typename_uppercase(files: FileList, typename: = str) -> Optional[str]: =20 def find_type_checkers(files:FileList, name:str, group:str=3D'uppercase') = -> Iterable[TypeCheckerDeclaration]: """Find usage of DECLARE*CHECKER macro""" - c: Type[TypeCheckerDeclaration] + c: type[TypeCheckerDeclaration] for c in (DeclareInstanceChecker, DeclareClassCheckers, DeclareObjChec= kers, ObjectDeclareType, ObjectDeclareSimpleType): yield from files.find_matches(c, name=3Dname, group=3Dgroup) =20 @@ -775,8 +810,8 @@ class InitialIncludes(FileMatch): n=3D'*', name=3D'includes')) =20 class SymbolUserList(NamedTuple): - definitions: List[FileMatch] - users: List[FileMatch] + definitions: list[FileMatch] + users: list[FileMatch] =20 class MoveSymbols(FileMatch): """Handle missing symbols @@ -790,7 +825,7 @@ def gen_patches(self) -> Iterator[Patch]: self.debug("skipping object.h") return =20 - index: Dict[RequiredIdentifier, SymbolUserList] =3D {} + index: dict[RequiredIdentifier, SymbolUserList] =3D {} definition_classes =3D [SimpleTypedefMatch, FullStructTypedefMatch= , ConstantDefine, Include] user_classes =3D [TypeCheckMacro, DeclareObjCheckers, DeclareInsta= nceChecker, DeclareClassCheckers, InterfaceCheckMacro] =20 diff --git a/scripts/codeconverter/codeconverter/qom_type_info.py b/scripts= /codeconverter/codeconverter/qom_type_info.py index 4ecdd728890..76fcf498f58 100644 --- a/scripts/codeconverter/codeconverter/qom_type_info.py +++ b/scripts/codeconverter/codeconverter/qom_type_info.py @@ -5,14 +5,49 @@ # # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. +from collections.abc import Iterable +import logging import re +from typing import Optional, Union =20 -from .patching import * -from .qom_macros import * -from .regexps import * -from .utils import * +from .patching import ( + FileInfo, + FileList, + FileMatch, + Patch, + RegexpScanner, +) +from .qom_macros import ( + DeclareClassCheckers, + DeclareInstanceChecker, + DeclareObjCheckers, + ExpressionDefine, + OldStyleObjectDeclareSimpleType, + SimpleTypedefMatch, + TypeDeclaration, + TypeDeclarationFixup, + find_type_checkers, + find_typename_uppercase, +) +from .regexps import ( + CPP_SPACE, + NAMED, + OR, + RE_ARRAY, + RE_ARRAY_ITEM, + RE_COMMENTS, + RE_EXPRESSION, + RE_IDENTIFIER, + RE_SIZEOF, + SP, + M, + S, +) =20 =20 +logger =3D logging.getLogger(__name__) +DBG =3D logger.debug + TI_FIELDS =3D [ 'name', 'parent', 'abstract', 'interfaces', 'instance_size', 'instance_init', 'instance_post_init', 'instance_fina= lize', 'class_size', 'class_init', 'class_base_init', 'class_data'] @@ -27,7 +62,7 @@ RE_TYPEINFO_START =3D S(r'^[ \t]*', M(r'(static|const)\s+', name=3D'modifi= ers'), r'TypeInfo\s+', NAMED('name', RE_IDENTIFIER), r'\s*=3D\s*{[ \t]*\n') =20 -ParsedArray =3D List[str] +ParsedArray =3D list[str] ParsedInitializerValue =3D Union[str, ParsedArray] =20 class ArrayItem(FileMatch): @@ -57,7 +92,7 @@ def parsed(self) -> ParsedInitializerValue: return array.parsed() return parsed =20 -TypeInfoInitializers =3D Dict[str, FieldInitializer] +TypeInfoInitializers =3D dict[str, FieldInitializer] =20 class TypeDefinition(FileMatch): """ @@ -341,7 +376,9 @@ def gen_patches(self) -> Iterable[Patch]: =20 ok =3D True =20 - #checkers: List[TypeCheckerDeclaration] =3D list(find_type_checker= s(self.allfiles, uppercase)) + #checkers: list[TypeCheckerDeclaration] =3D list( + # find_type_checkers(self.allfiles, uppercase) + #) #for c in checkers: # c.info("instance type checker declaration (%s) is here", c.gr= oup('uppercase')) #if not checkers: @@ -446,7 +483,11 @@ class ObjectDefineType(TypeDefinition): r'\s*\);?\n?') =20 def find_type_definitions(files: FileList, uppercase: str) -> Iterable[Typ= eDefinition]: - types: List[Type[TypeDefinition]] =3D [TypeInfoVar, ObjectDefineType, = ObjectDefineTypeExtended] + types: list[type[TypeDefinition]] =3D [ + TypeInfoVar, + ObjectDefineType, + ObjectDefineTypeExtended + ] for t in types: for m in files.matches_of_type(t): m.debug("uppercase: %s", m.uppercase) @@ -456,9 +497,12 @@ def find_type_definitions(files: FileList, uppercase: = str) -> Iterable[TypeDefin =20 class AddDeclareVoidClassType(TypeDeclarationFixup): """Will add DECLARE_CLASS_TYPE(..., void) if possible""" - def gen_patches_for_type(self, uppercase: str, - checkers: List[TypeDeclaration], - fields: Dict[str, Optional[str]]) -> Iterable= [Patch]: + def gen_patches_for_type( + self, + uppercase: str, + checkers: list[TypeDeclaration], + fields: dict[str, Optional[str]], + ) -> Iterable[Patch]: defs =3D list(find_type_definitions(self.allfiles, uppercase)) if len(defs) > 1: self.warn("multiple definitions for %s", uppercase) @@ -552,7 +596,10 @@ def gen_patches(self) -> Iterable[Patch]: if not self.file.force: return =20 - decl_types: List[Type[TypeDeclaration]] =3D [DeclareClassCheckers,= DeclareObjCheckers] + decl_types: list[type[TypeDeclaration]] =3D [ + DeclareClassCheckers, + DeclareObjCheckers + ] class_decls =3D [m for t in decl_types for m in self.allfiles.find_matches(t, uppercase, '= uppercase')] =20 @@ -632,7 +679,10 @@ def gen_patches(self) -> Iterable[Patch]: if not self.file.force: return =20 - decl_types: List[Type[TypeDeclaration]] =3D [DeclareClassCheckers,= DeclareObjCheckers] + decl_types: list[type[TypeDeclaration]] =3D [ + DeclareClassCheckers, + DeclareObjCheckers + ] class_decls =3D [m for t in decl_types for m in self.allfiles.find_matches(t, uppercase, '= uppercase')] if class_decls: diff --git a/scripts/codeconverter/codeconverter/test_patching.py b/scripts= /codeconverter/codeconverter/test_patching.py index b125eee2b72..4e5165a8014 100644 --- a/scripts/codeconverter/codeconverter/test_patching.py +++ b/scripts/codeconverter/codeconverter/test_patching.py @@ -7,13 +7,8 @@ # the COPYING file in the top-level directory. from tempfile import NamedTemporaryFile =20 -from .patching import ( - FileInfo, - FileList, - FileMatch, - Patch, -) -from .regexps import * +from .patching import FileInfo, FileList, FileMatch +from .regexps import NAMED, RE_IDENTIFIER, S =20 =20 class BasicPattern(FileMatch): diff --git a/scripts/codeconverter/codeconverter/test_regexps.py b/scripts/= codeconverter/codeconverter/test_regexps.py index 86d0499c50e..deba604361b 100644 --- a/scripts/codeconverter/codeconverter/test_regexps.py +++ b/scripts/codeconverter/codeconverter/test_regexps.py @@ -5,9 +5,35 @@ # # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. -from .qom_macros import * -from .qom_type_info import * -from .regexps import * + +import re + +from .qom_macros import ( + RE_CHECK_MACRO, + RE_MACRO_DEFINE, + RE_STRUCT_TYPEDEF, + InitialIncludes, +) +from .qom_type_info import ( + RE_TI_FIELD_INIT, + RE_TI_FIELDS, + RE_TYPEINFO_START, + TypeInfoVar, +) +from .regexps import ( + CPP_SPACE, + RE_ARRAY, + RE_ARRAY_CAST, + RE_ARRAY_ITEM, + RE_COMMENT, + RE_COMMENTS, + RE_EXPRESSION, + RE_FUN_CALL, + RE_IDENTIFIER, + RE_MACRO_CONCAT, + RE_SIMPLE_VALUE, + SP, +) =20 =20 def test_res() -> None: diff --git a/scripts/codeconverter/codeconverter/utils.py b/scripts/codecon= verter/codeconverter/utils.py index ced81a76486..b39cfb8b7d1 100644 --- a/scripts/codeconverter/codeconverter/utils.py +++ b/scripts/codeconverter/codeconverter/utils.py @@ -6,7 +6,12 @@ # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. import logging -from typing import * +from typing import ( + NamedTuple, + NewType, + Optional, + TypeVar, +) =20 =20 logger =3D logging.getLogger(__name__) --=20 2.48.1