Bug 28821 - use mypy type annotations
Summary: use mypy type annotations
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 11.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-25 21:05 UTC by Tom Tromey
Modified: 2022-07-08 18:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2022-01-25 21:05:00 UTC
It might be nice if gdb's Python API supplied mypy type annotations.
See http://mypy-lang.org/
Maybe this can be done via stub files:
https://mypy.readthedocs.io/en/latest/stubs.html
Comment 1 Alexander Fasching 2022-01-26 13:12:25 UTC
I think stubs should be added to typeshed instead of maintaining them in the GDB project:
https://github.com/python/typeshed

New mypy releases would then include them, so it's not necessary to mess with mypy settings and updates would be much faster.
Comment 2 Tom Tromey 2022-02-19 16:13:01 UTC
Adding them to an external project seems like it would have some
drawbacks.  They'd have to be maintained separately from gdb itself,
and it seems like there would be some version skew.

Is there a problem with maintaining them in gdb?
Actually I was wondering if we could use some technique
to ensure that they have to be up-to-date in the gdb tree,
like generating code from some kind of .def file or the like.
Comment 3 Alexander Fasching 2022-02-20 05:18:14 UTC
You are probably right.
Maintaining it in GDB also avoids problems with different versions.

I was initially thinking about the update process. Mypy and typeshed are updated quite often, so this would also apply for the annotations. The annotations aren't too complicated though, so this is only a minor concern once they are good enough.
Comment 4 Tom Tromey 2022-02-21 15:44:23 UTC
I hadn't considered changes in mypy -- that's a good point.
Comment 5 Tom Tromey 2022-07-08 18:55:03 UTC
These are in typeshed now:

https://github.com/python/typeshed/tree/master/stubs/gdb