gi: expose a __signature__ attribute on CallableInfo objects
This is a first go at implementing #479 (closed) (expose function signatures).
I'm providing a __signature__
attribute that delegates to a new gi._signature
module to build an inspect.Signature
object for Callables, similar to the docstring code. This means the complex logic is written Python making it simpler and easier to maintain.
I had to revert 78976869 for the gi.FunctionInfo objects to be recognised as method descriptors. I'm not sure what the proper fix would be for the bug referenced there, but that change looks wrong.
The signatures include type annotations, attempting to convert GIR style type information to Python style equivalents. For example:
| get_cursor_locations(self, iter: Optional[gi.overrides.Gtk.TextIter] = None) -> tuple[gi.repository.Gdk.Rectangle, gi.repository.Gdk.Rectangle]
There's still some room to improve (e.g. implement callback type annotations), but it already covers the majority of functions/methods.