Coding 2023-05-03

By Max Woerner Chase

I don't feel like touching MOTR directly right now, so let's take a look at how Mypy supports attrs.evolve.

It expects two args (inst and **changes?). Then it mostly focuses on args[0][0]. Is Mypy's usage of nested lists documented anywhere? I don't remember understanding it with the last plugin I wrote, just figuring out what made the test cases pass.

Anyway, it gets the type of inst, and operates on that. There's a helper function I'm going to have to get access to, which determines the types of the fields. Once the fields are gotten, it does a bunch of stuff that's pretty straightforward for evolve, and will be less so for saltate.

Let's see what's different.

In any case, let's work through this in order.

That gets us to fields, and the check we need to make is whether a given inst field is a subtype of the corresponding typ field. Ah, that's what mypy.subtypes.is_subtype is for.

I think that's all the information I need to write the hook for saltate. I'm going to hold off on writing it, because I still want to figure out stuff like where to put it. Judging by how I positioned other general-purpose stuff, it looks like it should go in a module right under the motr package. (At least, until and if it gets its own package.)

Let's see if I'm up for working on this properly tomorrow.

Good night.