Skip to content

Commit

Permalink
Make TestRenderer to be generics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Liraim committed Oct 23, 2024
1 parent 5628c8b commit 53d3b7b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/evidently/renderers/base_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import warnings
from typing import TYPE_CHECKING
from typing import Dict
from typing import Generic
from typing import List
from typing import Optional
from typing import TypeVar
from typing import Union

import pandas as pd
Expand Down Expand Up @@ -78,14 +80,17 @@ def with_details(self, title: str, info: BaseWidgetInfo):
return self


class TestRenderer(BaseRenderer):
def html_description(self, obj: "Test"):
TTest = TypeVar("TTest", bound="Test")


class TestRenderer(Generic[TTest], BaseRenderer):
def html_description(self, obj: TTest):
return obj.get_result().description

def json_description(self, obj: "Test"):
def json_description(self, obj: TTest):
return obj.get_result().description

def render_html(self, obj: "Test") -> TestHtmlInfo:
def render_html(self, obj: TTest) -> TestHtmlInfo:
result = obj.get_result()
return TestHtmlInfo(
name=result.name,
Expand All @@ -97,7 +102,7 @@ def render_html(self, obj: "Test") -> TestHtmlInfo:

def render_json(
self,
obj: "Test",
obj: TTest,
include_render: bool = False,
include: "IncludeOptions" = None,
exclude: "IncludeOptions" = None,
Expand Down

0 comments on commit 53d3b7b

Please sign in to comment.