[libre-riscv-dev] mypy type annotations for nmigen

Luke Kenneth Casson Leighton lkcl at lkcl.net
Thu Mar 14 02:32:32 GMT 2019


On Wed, Mar 13, 2019 at 6:16 PM Jacob Lifshay <programmerjake at gmail.com>
wrote:

> On Tue, Mar 12, 2019, 22:12 Luke Kenneth Casson Leighton <lkcl at lkcl.net>
> wrote:
>
> > On Wed, Mar 13, 2019 at 4:55 AM Jacob Lifshay <programmerjake at gmail.com>
> > wrote:
>
> I don't know how much it reduces bugs since I don't have enough experience,
>

ok let's see how it goes.  keep an eye on the amount of effort vs payoff.

i suspect it will be of minimal use as we are just simply not developing
significant amounts of code that go outside of nmigen, and nmigen is
designed to be dynamic.  you ran into one issue with submodules already.
the trick about creating wrapper classes Signal1, Signal2.... Signal89 will
help _partially_ alleviate that, however it's... yeah.


> but, for me, it actually decreases total development effort because of
> auto-completion.


that's an interesting side-effect.  one that would have helped enormously
with some of the absolutely massive code-bases i've seen people work with.


> If I was writing the code without auto-completion, I'd
> estimate that static typing increases the effort required by a few percent
> since in a lot of cases the only annotations required are on function
> definitions and they tend to be simple.
>
> >
> >  as i explained in the previous message: given that we are using nmigen,
> > and that nmigen is itself not using static typing, the benefits are not
> > clear.
> >
> I added the static type annotation files (*.pyi) so mypy can work with most
> nmigen code as if nmigen was statically typed.
>
>
apologies that took me a while to understand: then yes, it should be a
different repo, maintained separately, and included as a git submodule
where needed.


> >
> > can you demonstrate *clear* benefits for the effort that is projected to
> be
> > expended, or demonstrate that the effort to be expended is minimal and
> > effective?
> >
> for me, yes. For everyone else, that depends on if they are using pyls or
> not. In any case the effort required seems minimal, and I found it to be
> effective for me.
>
>
ok, that's a good assessment, and a good justification.

l.


More information about the libre-riscv-dev mailing list