Coverage for src/python/ensembl/vep/stats/report.py: 100%
13 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-18 14:41 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-18 14:41 +0000
1# See the NOTICE file distributed with this work for additional information
2# regarding copyright ownership.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Report contracts and rendering."""
16from __future__ import annotations
18from typing import Protocol, runtime_checkable
20from ensembl.vep.render.report import ReportFormat, ReportSection, render_report
22__all__ = ["Reportable", "render_reportable"]
25@runtime_checkable
26class Reportable(Protocol):
27 """Anything that can be rendered as a report.
29 Members are properties rather than attributes: the implementers are frozen attrs classes, and
30 a Protocol declaring a plain attribute demands a settable one.
31 """
33 @property
34 def title(self) -> str:
35 """Return the document title."""
37 @property
38 def subtitle(self) -> str:
39 """Return one line shown under the title."""
41 def sections(self) -> tuple[ReportSection, ...]:
42 """Return the report sections in rendering order."""
45def render_reportable(report: Reportable, report_format: str | ReportFormat) -> str:
46 """Render any report in the requested format."""
47 return render_report(report.title, report.subtitle, report.sections(), report_format)