We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I really like @indexedproperty, it saves a lot of boilerplate code.
@indexedproperty
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?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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:
Is there a way around this?
The text was updated successfully, but these errors were encountered: