Coding 2023-05-04

Tags:
By Max Woerner Chase

Well, I bashed out code for the saltate plugin last night, but it turns out that trying to make the actual implementation have mildly reasonable annotations causes Mypy to raise a bunch of sensible objections that I don't really know what to do about. I could loosen the annotations and try to put more type-checking smarts on the plugin, but that would mean that nearly anything would typecheck without the plugin.

One of the issues is, I'd really like to be able to bound a TypeVar as "any attrs class", and according to my intuition and a cursory Google search, that's not a thing.

Let's review:

I don't think there's any sensible way to express the desired relationship between T and U. If I could just express "Hey, this is some attrs class..."

Actually... If I could just forbid it from typechecking without the plugin rewriting the signature? Hm.

So, like, if I created a typing-only attrs class? This is a silly idea; I have to try it.

...

That

worked

???

It all typechecks, despite clearly being objectively ludicrous. "Here, reinstantiate this class that doesn't exist with arguments that it wouldn't take if it did."

Well, next up is seeing whether the plugin actually works. I don't have the stamina to write the tests currently, and I also need to update the requirements file for testing, which is probably going to slow it down even more.

But, anyway, that's one obstacle knocked down.

We'll see when I'm up for more. For now, I'm going to wind down and get to bed.

Good night.