Improve invalidation checking to InvalidatableMixin.
Review Request #15189 — Created July 21, 2026 and updated — Latest diff uploaded
Initially, invalidation support was limited to
BaseKey, though it
was moved out early in development toInvalidatableMixin. The one
piece remaining inBaseKeywascheck_valid(), which raised a
KeyInvalidatedErrorif no longer valid.This change renames the exception to
InvalidatedErrorand moves
check_valid()out into the mixin, so that any invalidatable object can
perform these validity checks. It's been renamed toassert_valid(), to
make its purpose more clear.When used as a context manager, invalidatable objects will now start
with a validity assertion, to avoid any surprises and catch problems
early.
Unit tests pass.