Coding 2025-08-22
I know there are some typos in the code from last post, but the bigger issue is that typing descriptors is... frustrating, and I ended up going with a solution that was just simple enough that Mypy couldn't totally biff it:
class Failing(Protocol):
@classmethod
def failure(cls) -> Self: ...
def coerce[T: Failing](
cls: type[T], bundle: Bundle[Any]
) -> Constraints[Bundle[T]]:
obj = bundle.data
if isinstance(obj, cls):
return Bundle(obj, bundle.metadata)
yield from ()
return bundle.extend(lambda _: cls.failure(), CoercionFailure())
With this, I have what I need to be confident updating the rest of the nodes. I think.
Anyway, it's late and I'm tired.
Good night.