typing.NamedTuple was already mentioned in this discussion, I just would like to add few comments:
1. I think that changing Python syntax to support declarative classes is not a realistic option in nearby future.
In contrast, there is an existing syntax change - variable annotations - that can be actively experimented with.
Variable annotations are designed to play well with metaclass machinery, for example, they will respect
__prepare__ method, if it injects __annotations__ as a custom mapping, etc.
2. Possible strategy for declarative classes could be developing independent *composable* mixins/traits:
class MyClass(Comparable, Pickleable):
The problem with the second approach is that it can lead to metaclass conflicts. A possible solution will
be to provide a standard metaclass for mixins in stdlib.
3. Composability could be a problem if only normal variable assignments are used: after one mixin transforms the class,
the original declarations are lost. Simple possible solution would be to agree that mixins should *not* modify
__annotations__, only __dict__. Currently, PEP 484 and PEP 526 specify that preferable use of annotations is type
declarations. However, I think this can be generalized to just declarations. For example, by providing a special typing
construct that will allow additional info apart from type:
return val > 42
x: Spec(int, validator=large)
y: Spec(List[int], default_factory=list)