aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorChristian Tismer <[email protected]>2025-03-03 15:22:30 +0100
committerChristian Tismer <[email protected]>2025-03-04 13:09:57 +0100
commit2ccb5f59c76ae4c0c1d9745e8751f99b82c8c15d (patch)
treedca2472c97ebbba2102ad4846450cb4c207259ad /sources/shiboken6
parentc253dcda92cc2efb45197190beaccb926afb120c (diff)
type hints: Modernize part of the signature parser
Using a class for initialization and the re.finditer method which was introduced in Python 3.7 . Task-number: PYSIDE-3012 Change-Id: Id9d4b9a72789dbcab4c31ab83dc721d728878067 Pick-to: 6.8 Reviewed-by: Friedemann Kleint <[email protected]>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index cc5bbe15a..050a60085 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -109,21 +109,21 @@ def dprint(*args, **kw):
sys.stdout.flush()
-_cache = {}
+class ArglistParser:
+ def __init__(self):
+ regex = build_brace_pattern(level=3, separators=",")
+ rec = re.compile(regex, flags=re.VERBOSE)
+ self._finditer = rec.finditer
+
+ def parse(self, argstr):
+ return list(x.group(1).strip() for x in self._finditer(argstr))
+
+
+arglistParser = ArglistParser()
def _parse_arglist(argstr):
- # The following is a split re. The string is broken into pieces which are
- # between the recognized strings. Because the re has groups, both the
- # strings and the separators are returned, where the strings are not
- # interesting at all: They are just the commata.
- key = "_parse_arglist"
- if key not in _cache:
- regex = build_brace_pattern(level=3, separators=",")
- _cache[key] = re.compile(regex, flags=re.VERBOSE)
- split = _cache[key].split
- # Note: this list is interspersed with "," and surrounded by ""
- return [x.strip() for x in split(argstr) if x.strip() not in ("", ",")]
+ return arglistParser.parse(argstr)
def _parse_line(line):
@@ -333,7 +333,7 @@ def get_from_another_module(thing):
type_map[thing] = res
return res
except AttributeError:
- # Maybe it was anothr module...
+ # Maybe it was another module...
pass
return None