[New-bugs-announce] [issue40749] Consider adding decorator for required inner class
Elijah Rippeth
report at bugs.python.org
Sat May 23 19:07:34 EDT 2020
New submission from Elijah Rippeth <elijah.rippeth at gmail.com>:
Sometimes it's desirable to couple classes together by nesting. Currently there's no way to signal to an interface implementer that an inner class is a required attribute to be implemented.
I propose a decorator for `abstractnestedclass` to fill this gap. A simple example use-case is outlined below:
```
from abc import ABCMeta, abstractnestedclass
class BaseComponent(metaclass=ABCMeta):
@abstractnestedclass
class Config:
pass
class MissingNestedComponent(BaseComponent):
# This will raise when constructed because
# BaseComponent.Config is not implemented
pass
class NonraisingComponent(BaseComponent):
# This will be constructable
class NonraisingComponentConfig(BaseComponent.Config):
pass
pass
```
----------
components: Library (Lib)
messages: 369756
nosy: Elijah Rippeth
priority: normal
severity: normal
status: open
title: Consider adding decorator for required inner class
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40749>
_______________________________________
More information about the New-bugs-announce
mailing list