classification
Title: Consider adding decorator for required inner class
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Elijah Rippeth
Priority: normal Keywords:

Created on 2020-05-23 23:07 by Elijah Rippeth, last changed 2020-05-23 23:07 by Elijah Rippeth.

Messages (1)
msg369756 - (view) Author: Elijah Rippeth (Elijah Rippeth) Date: 2020-05-23 23:07
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
```
History
Date User Action Args
2020-05-23 23:07:34Elijah Rippethcreate