sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Python domain: Correctly match when signature simultaneously has annotations for both the function and the return type

Open arashbm opened this issue 1 year ago • 2 comments

Feature or Bugfix

  • Bugfix

Purpose

  • Fixes python signature regex to successfully parse simultaneous annotations of function and return type.

Detail

Python domain fails to match functions where both function name and return type have type annotation, e.g.

hello[int](a, b, c) -> world[int]

The fix comes down to an overly eager .* in the regex that matches everything from the first [ to the last ] in one fell swoop.

I'm not 100% sure if the two new test cases are in the right place but if not, let me know and I'll move them.

arashbm avatar Dec 12 '23 03:12 arashbm

Ok, this one is propably my bad. Before reviewing it-, I want you to complete the tests that I wrote for PEP 695 (https://github.com/sphinx-doc/sphinx/blob/35965903177c6ed9a6afb62ccd33243a746a3fc0/tests/test_domain_py.py#L1849 and later) and check whether they still pass with a return value because I totally missed that case.

I really don't like regexes like that because we always miss some cases...

Note: I'm only quickly available for a week or so before going off until mid february.

Note 2: Can you open a dedicated issue also?

picnixz avatar Dec 24 '23 10:12 picnixz