Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AbstractVars are now overriden by annotations in subclasses.
When subclassing, it used to be the case that `cls.__abstractvars__` basically never got smaller (only if an element was overriden by a class-level attribute or method): ```python class Foo(eqx.Module): x: AbstractVar[bool] class Bar(eqx.Module): x: bool Bar.__abstractvars__ == frozenset({"x"}) ``` This was intended -- the idea is that the all abstractvars would get checked during initialisation, i.e. validity wrt this condition being a property of the instance, rather than being a property of just the class object. With this change, the above example will remove `x` from `__abstractvars__`. This is because it's useful and typical to reason about whether a class is abstract or not -- it's much more annoying to have to reason about whether each individual instance is abstract. Indeed the recent changes to `eqx.Module`, in strict mode, are a use case in which want to be able to reason about things in this way. Thus, any element of either `subcls.__dict__` or `subcls.__annotations__` can be used to concretise any abstract variable, rather than just doing `hasattr(self, var)` during initialisation.
- Loading branch information