Make classes more generic

This commit is contained in:
Joscha 2019-06-03 15:55:58 +00:00
parent f4c0416398
commit 052bbfb6d2
5 changed files with 265 additions and 0 deletions

View file

@ -0,0 +1,18 @@
from abc import ABC, abstractmethod
from typing import Generic, List, TypeVar
from .element import Element, RenderedElement, MetaRenderedElement
from .markup import AttributedText
__all__ = ["ElementRenderer"]
E = TypeVar("E", bound=Element)
class ElementRenderer(ABC, Generic[E]):
"""
Knows how to render elements.
"""
@abstractmethod
def render(self, element: E, width: int) -> RenderedElement:
pass