public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 3/9] gdb: gdbarch.py: spell out parameters of _Component.__init__
Date: Fri, 24 Feb 2023 15:31:59 -0500	[thread overview]
Message-ID: <3a019b47-5dab-def1-807c-c8fbcf63872e@polymtl.ca> (raw)
In-Reply-To: <87bklihmf6.fsf@tromey.com>

On 2/24/23 14:51, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> From: Simon Marchi <simon.marchi@polymtl.ca>
> Simon> The way _Component uses kwargs is handy to save a few characters, but it
> Simon> doesn't play well with static analysis.  When editing gdbarch.py, my
> Simon> editor (which uses pylance under the hood) knows nothing about the
> Simon> properties of components.  So it's full of squiggly lines, and typing
> Simon> analysis (which I find really helpful) doesn't work.  I therefore think
> Simon> it would be better to spell out the parameters.
> 
> Simon> @@ -87,7 +112,7 @@ class Value(_Component):
> Simon>          name,
> Simon>          type,
> Simon>          comment=None,
> Simon> -        predicate=None,
> Simon> +        predicate=False,
> 
> This changes the type of predicate, which is fine, but there's still a
> spot that does:
> 
>         # This little hack makes the generator a bit simpler.
>         self.predicate = None

Huh, it's unfortunate that the type checker does not understand at this
point that predicate (set in _Component.__init__ is a bool).  It does
understand it at other places.

I don't understand why this assignment to None is there though.  Wasn't
predicate None by default anyway?  Can we remove it, and in turn remove
Info.__init__?  If I do that, I see no diff in the generated files.

Simon

Simon

  reply	other threads:[~2023-02-24 20:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 22:18 [PATCH 0/9] Add typing annotations to gdbarch*.py and make-target-delegates.py Simon Marchi
2023-02-23 22:18 ` [PATCH 1/9] gdb: remove invalid / dead code from gdbarch.py Simon Marchi
2023-02-23 22:18 ` [PATCH 2/9] gdb: reformat Python files with black 23.1.0 Simon Marchi
2023-02-23 22:18 ` [PATCH 3/9] gdb: gdbarch.py: spell out parameters of _Component.__init__ Simon Marchi
2023-02-24 19:51   ` Tom Tromey
2023-02-24 20:31     ` Simon Marchi [this message]
2023-02-24 22:07       ` Tom Tromey
2023-02-23 22:18 ` [PATCH 4/9] gdb: pyproject.toml: set pyright typeCheckingMode = "strict" Simon Marchi
2023-02-23 22:18 ` [PATCH 5/9] gdb: split gdbarch component types to gdbarch_types.py Simon Marchi
2023-02-23 22:18 ` [PATCH 6/9] gdb: gdbarch*.py, copyright.py: add type annotations Simon Marchi
2023-02-23 22:18 ` [PATCH 7/9] gdb: make-target-delegates.py: make one string raw Simon Marchi
2023-02-23 22:18 ` [PATCH 8/9] gdb: make-target-delegates.py: add Entry type Simon Marchi
2023-02-23 22:18 ` [PATCH 9/9] gdb: make-target-delegates.py: add type annotations Simon Marchi
2023-02-24 19:54 ` [PATCH 0/9] Add typing annotations to gdbarch*.py and make-target-delegates.py Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a019b47-5dab-def1-807c-c8fbcf63872e@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).