-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I really like @indexedproperty, it saves a lot of boilerplate code.
When trying to create an indexed property in an abstract class, ABC is stopping me from instantiation, see this simplified example:
from abc import ABC
from typing import Dict
from indexedproperty import indexedproperty
class A(ABC):
def __init__(self):
self._books: Dict[str, str] = {'U001': 'John', 'U002': 'Mark', 'U003': 'Paul'}
@indexedproperty
def book(self, uid: str) -> str:
return self._books.get(uid, '[Unknown]')
class TestA:
def test_something(self):
assert A().book['U001'] == 'John'
# > assert A().book['U001'] == 'John'
# E TypeError: Can't instantiate abstract class A with abstract method book
Is there a way around this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels