Weekly Roundup 2020-11-10

By Max Woerner Chase

Next week, I'm going to have to figure out how best to continue with the punq fork I'm developing. Adding typing to the current state of it is... not happening. I guess I should be working on tests, or maybe just... I don't need to keep using limit-coverage for now. So, let's comment that out of the noxfile and see what kind of raw coverage numbers we get... All right, I can confirm that, in spite of what punq's coverage badge says, it gets full coverage.

All right, remembering one of the directions I wanted to go all that time ago, I kind of wanted to make it canonicalize on string representations of types, but being aware of aliases.

Let me see if I remember the logic.

From the annotation side, given a string annotation in the context of a module, I want to assume that the name before the final dot evaluates to a module, and that module contains the remainder of the name, and that if the __name__ attribute of the class matches the name, then the canonical name is the __qualname__ of the class, and that otherwise, the canonical name is the __name__ of the module and the original RHS.

From the registration side, passing a class is shorthand for passing its __qualname__ (and probably similarly for resolution). I want to avoid going too far with stack introspection, so I'll probably just want a helper function that basically takes (module, alias) to f"{module.__name__}.{alias}" and is more compact.

I think I can work from here. I've got a few more ideas that are a bit less fleshed out, but also less fundamental, so I'm okay leaving them sketchy for now.

Quick notes for my future self:

Okay, that's enough poking at the code and design. Done for now.