[0/9] Add typing annotations to gdbarch*.py and make-target-delegates.py

Message ID 20230223221830.499934-1-simon.marchi@efficios.com
Headers
Series Add typing annotations to gdbarch*.py and make-target-delegates.py |

Message

Simon Marchi Feb. 23, 2023, 10:18 p.m. UTC
  While investigating something related to a gdbarch method, I was trying
to understand the purpose of the "invalid" Function parameter.  It is
sometimes passed a boolean and sometimes passed a string.  This is
indeed described in the comment at the top of gdbarch-components.py, but
I then thought that if we used type annotations, it would make it clear
that it's intended.  Also, I find type annotations (when paired with a
checker such as pyright or pylance) really handy to avoid all kinds of
mistake.  So I got a bit carried away, and this series is the result.

Simon Marchi (9):
  gdb: remove invalid / dead code from gdbarch.py
  gdb: reformat Python files with black 23.1.0
  gdb: gdbarch.py: spell out parameters of _Component.__init__
  gdb: pyproject.toml: set pyright typeCheckingMode = "strict"
  gdb: split gdbarch component types to gdbarch_types.py
  gdb: gdbarch*.py, copyright.py: add type annotations
  gdb: make-target-delegates.py: make one string raw
  gdb: make-target-delegates.py: add Entry type
  gdb: make-target-delegates.py: add type annotations

 gdb/gdbarch.py                                | 161 +--------------
 ...ch-components.py => gdbarch_components.py} |   8 +-
 gdb/gdbarch_types.py                          | 189 ++++++++++++++++++
 gdb/gdbcopyright.py                           |   2 +-
 gdb/make-target-delegates.py                  | 104 +++++++---
 gdb/pyproject.toml                            |   3 +
 gdb/python/lib/gdb/FrameDecorator.py          |   1 -
 gdb/python/lib/gdb/command/frame_filters.py   |   1 +
 gdb/python/lib/gdb/dap/server.py              |   2 +-
 gdb/python/lib/gdb/printing.py                |   2 +-
 .../gdb.multi/multi-target-info-inferiors.py  |   1 +
 gdb/testsuite/gdb.perf/backtrace.py           |   1 -
 .../gdb.python/py-framefilter-addr.py         |   1 +
 gdb/testsuite/gdb.python/py-framefilter.py    |   1 +
 gdb/testsuite/gdb.python/py-inferior-leak.py  |   2 +
 gdb/testsuite/gdb.python/py-prettyprint.py    |   1 +
 gdb/testsuite/gdb.python/py-recurse-unwind.py |   5 -
 gdb/testsuite/gdb.python/py-send-packet.py    |   1 +
 gdb/testsuite/gdb.python/tui-window.py        |   1 +
 19 files changed, 290 insertions(+), 197 deletions(-)
 rename gdb/{gdbarch-components.py => gdbarch_components.py} (99%)
 create mode 100755 gdb/gdbarch_types.py
  

Comments

Tom Tromey Feb. 24, 2023, 7:54 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> While investigating something related to a gdbarch method, I was trying
Simon> to understand the purpose of the "invalid" Function parameter.  It is
Simon> sometimes passed a boolean and sometimes passed a string.  This is
Simon> indeed described in the comment at the top of gdbarch-components.py, but
Simon> I then thought that if we used type annotations, it would make it clear
Simon> that it's intended.  Also, I find type annotations (when paired with a
Simon> checker such as pyright or pylance) really handy to avoid all kinds of
Simon> mistake.  So I got a bit carried away, and this series is the result.

This all seems fine to me, though I found one it.

Reviewed-By: Tom Tromey <tom@tromey.com>

Tom