Coding 2023-05-20

By Max Woerner Chase

Iiii got distracted.

However, I also noticed and fixed another issue in the saltate plugin. I'm not sure how that code is handling being such a bundle of issues...

Anyway, the problem was, I was erasing types too aggressively. Technically, this isn't a problem for my use case, because I barely use subclassing. But from a theoretical perspective...

Basically, if you have a class Base(Generic[T]) and a class Derived(Base[int]), then it can't be sound to treat a Derived as a Base[str]. Or any other example you care to come up with.

The solution is simple: for the subtype check (which I mostly have in place to deal with unions), erase the types on the inst arg, but not on the typ.

I still need to work out what I want it to do for non-final classes. I guess I can argue: "It might not be valid, but if it is, then the return value is of type typ, and any attribute on inst but not typ is, let's say required and of type Any, and if inst is non-final, maybe add a **kwargs: Any of some kind, except I'm not sure how to handle name collisions in that case..."

I'll think about it some more, but right now, I let things get way too late and I need to get to bed.

Good night.