Coding 2023-04-23

Tags:
By Max Woerner Chase

I did a little work on MOTR after last night's entry, and I ended up with an idea that I'm not sure whether I should believe:

"Generic attributes should not have a default value in the base constructor, and the class can provide alternative constructors that do provide default values."

I may even consider a strong statement, starting instead with "Generic classes should not have default values for any attribute".

I'm pondering this, because I can't see a way to make evolve handle changing the parameters to the type; this means that "modified" values must be instantiated from scratch, and that means that, if I add another field to the class definition, it will be silently dropped from the update if it has a default value.

This has implications for:

Hm. Let's see how much it hurts if I start changing these...

So far, it hasn't been a big deal, but this seems fiddly enough to remember and to deal with that I'm now looking into semgrep, or maybe something similar, to check the codebase for a highly specific pattern. Like, "when a class has one of these decorators, and inherits from an expression involving instances of this type, make sure that any values set at the class level either have a specific type annotation, or the value is a call to a function that does not pass some specific arguments". Sure.

It's a bit late to write that right now, but I'll get on it tomorrow. For now, I want to wind down.

Good night.