[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-16 Thread Jacob Nilsson
Jacob Nilsson added the comment: Could one possible downside of this suggestion be, if implemented like in https://newbedev.com/python-abstract-class-shall-force-derived-classes-to-initialize-variable-in-init, a slowdown in code creating a lot of instances of a class with metaclass ABCMeta?

[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-16 Thread Alex Waygood
Alex Waygood added the comment: ^And, that only works for class attributes, not instance attributes. -- ___ Python tracker ___ ___

[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-16 Thread Alex Waygood
Alex Waygood added the comment: Tomasz -- as discussed in the original BPO issue for `abstractmethod` implementations (https://bugs.python.org/issue1706989), this works as a workaround: ``` >>> from abc import ABCMeta >>> class AbstractAttribute: ... __isabstractmethod__ = True ...

[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-13 Thread Alex Waygood
Alex Waygood added the comment: +1 to this suggestion. I had a use case for this the other day. It currently feels like something of a discrepancy between ABCs and `typing.Property`, which can be seen as analogous in some ways to "an ABC for the static type-checker". `typing.Property`

[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-13 Thread Jacob Nilsson
Change by Jacob Nilsson : -- nosy: +ajoino ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44905] Abstract instance and class attributes for abstract base classes

2021-08-12 Thread Tomasz Rzepecki
New submission from Tomasz Rzepecki : There seems to be no way to transparently make an abstract base class enforce instance attributes for subclasses (without creating a custom metaclass, see e.g.