New submission from Tomasz Rzepecki <rzepeck...@gmail.com>:

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. 
https://newbedev.com/python-abstract-class-shall-force-derived-classes-to-initialize-variable-in-init).

The analogous problem for enforcing *class* attributes in subclasses can be 
solved by creating an abstract class property (which can then be overridden by 
a class attribute), but this feels like a hack and possibly a bug (see 
https://bugs.python.org/issue44904 for a related bug).

The corresponding "solution" for instance attributes does not work (see 
attached file), and probably rightly so.

This seems like an oversight to me.

----------
files: example.py
messages: 399486
nosy: rzepecki.t
priority: normal
severity: normal
status: open
title: Abstract instance and class attributes for abstract base classes
type: enhancement
versions: Python 3.9
Added file: https://bugs.python.org/file50213/example.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44905>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to