Commit 8198f6c6 authored by Pierre Augier's avatar Pierre Augier
Browse files

Fix signature split (for cases like float[:,:])

parent f4209faea823
Pipeline #18023 passed with stage
in 10 minutes and 9 seconds
......@@ -14,6 +14,7 @@
"""
import re
from pprint import pformat
import gast as ast
......@@ -384,6 +385,9 @@ def analyse_aot(code, pathfile, backend_name):
annotations["__locals__"] = {}
annotations["__returns__"] = {}
# match a comma except if inside backets (for `float[:,:]`)
pattern = re.compile(r",\s*(?![^[]*\])")
for functions_backend in boosted_dicts["functions"].values():
for name_func, fdef in functions_backend.items():
try:
......@@ -395,7 +399,7 @@ def analyse_aot(code, pathfile, backend_name):
for sig in signatures:
types = [
type_.strip()
for type_ in sig[len(fdef.name) + 1 : -1].split(",")
for type_ in re.split(pattern, sig[len(fdef.name) + 1 : -1])
]
annotations_sign.append(dict(zip(arg_names, types)))
if annotations_sign:
......
......@@ -877,7 +877,6 @@ def str2type(str_type):
>>> str2type("(int, float[:, :])")
Tuple[int, Array[float, "2d"]]
"""
str_type = str_type.strip()
if " or " in str_type:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment