New submission from Elijah Rippeth <elijah.ripp...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue40749>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to