I have a annotation with numpy.ndarray[[('value', '<f8'), ('value', '<f8')]] and the stub generation will produce annotation as Annotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))]] a bracket misplaced
Line 634: sub will look for the leftmost match so s=[('value', '<f8'), ('value', '<f8') in the beginning and the return value is Annotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))] (which misses a right bracket), and because the rightmost bracket is not substituted, the resulting annotation becomes Annotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))]] with an extra outmost right bracket.
https://github.com/wjakob/nanobind/blob/bd6256570235f38a2c7a2193f2469cde00c7bca5/src/stubgen.py#L620-L634
Problem description
I have a annotation with
numpy.ndarray[[('value', '<f8'), ('value', '<f8')]]
and the stub generation will produce annotation asAnnotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))]]
a bracket misplacedI suspect the root cause is the nested brackets. Here is the matching rule. https://github.com/wjakob/nanobind/blob/bd6256570235f38a2c7a2193f2469cde00c7bca5/src/stubgen.py#L253-L256
Line 634: sub will look for the leftmost match so s=
[('value', '<f8'), ('value', '<f8')
in the beginning and the return value isAnnotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))]
(which misses a right bracket), and because the rightmost bracket is not substituted, the resulting annotation becomesAnnotated[ArrayLike, dict([('time', '<f8'), ('value', '<f8'))]]
with an extra outmost right bracket. https://github.com/wjakob/nanobind/blob/bd6256570235f38a2c7a2193f2469cde00c7bca5/src/stubgen.py#L620-L634Reproducible example code
No response