diff --git a/README.md b/README.md index c756811..91dd793 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Calculate the Type Coverage for top Python packages. This analysis aims to deter - Daily coverage calculator: [https://python-type-checking.com](https://python-type-checking.com/) - Coverage Trends: [https://python-type-checking.com/historical_data/coverage-trends.html](https://python-type-checking.com/historical_data/coverage-trends.html) - +- Prioritized Coverage Reports: [https://python-type-checking.com/prioritized/](https://python-type-checking.com/prioritized/) - Prioritized list of packages included in analysis with Pyright: https://github.com/lolpack/type_coverage_py/blob/main/included_packages.txt - Coverage trends for prioritized list: [https://python-type-checking.com/prioritized/historical_data/coverage-trends.html](https://python-type-checking.com/prioritized/historical_data/coverage-trends.html) diff --git a/analyzer/historical_view_generator.py b/analyzer/historical_view_generator.py index 98d9601..787d511 100644 --- a/analyzer/historical_view_generator.py +++ b/analyzer/historical_view_generator.py @@ -30,7 +30,7 @@ def collect_historical_data(data_dir: str) -> Dict[str, List[Dict[str, Any]]]: return historical_data -def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: str) -> None: +def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: str, prioritized: bool = False) -> None: html_template = """ @@ -139,7 +139,7 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: borderColor: 'rgb(255, 99, 132)', yAxisID: 'y2', tension: 0.1, - hidden: true + hidden: true }, { label: 'Param Coverage with Stubs', @@ -147,7 +147,7 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: borderColor: 'rgb(54, 162, 235)', yAxisID: 'y1', tension: 0.1, - hidden: true + hidden: {{ 'true' if prioritized else 'false' }} }, { label: 'Return Coverage with Stubs', @@ -155,7 +155,7 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: borderColor: 'rgb(75, 192, 192)', yAxisID: 'y1', tension: 0.1, - hidden: true + hidden: {{ 'true' if prioritized else 'false' }} }, { label: 'Parameter Coverage', @@ -163,7 +163,7 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: borderColor: 'rgb(153, 102, 255)', yAxisID: 'y1', tension: 0.1, - hidden: true + hidden: true }, { label: 'Return Coverage', @@ -171,14 +171,15 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: borderColor: 'rgb(255, 159, 64)', yAxisID: 'y1', tension: 0.1, - hidden: true + hidden: true }, { label: 'Pyright Coverage', data: {{ records | map(attribute='pyright_coverage') | list | safe }}, borderColor: 'rgb(255, 159, 64)', yAxisID: 'y1', - tension: 0.1 + tension: 0.1, + hidden: {{ 'false' if prioritized else 'true' }} } ] }, @@ -235,13 +236,14 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output: """ template = Template(html_template) - html_content = template.render(historical_data=historical_data) + html_content = template.render(historical_data=historical_data, prioritized=prioritized) with open(html_output, "w") as f: f.write(html_content) print("HTML generated successfully.") -def generate_historical_graphs(historical_data_dir: str, html_output: str) -> None: + +def generate_historical_graphs(historical_data_dir: str, html_output: str, prioritized: bool = False) -> None: historical_data = collect_historical_data(historical_data_dir) - generate_html(historical_data, html_output) + generate_html(historical_data, html_output, prioritized=prioritized) diff --git a/main.py b/main.py index cf06d29..3b5afb3 100644 --- a/main.py +++ b/main.py @@ -267,6 +267,7 @@ def main( package_list: Optional[str] = None, pyright_stats: Optional[bool] = False, output_list_only: Optional[bool] = False, + prioritized: bool = False ) -> None: package_report: dict[str, Any] = {} @@ -367,7 +368,7 @@ def main( if create_daily: update_main_html_with_links(html_report_file, historical_html_dir) - generate_historical_graphs(historical_json_dir, coverag_trends_html) + generate_historical_graphs(historical_json_dir, coverag_trends_html, prioritized=prioritized) if __name__ == "__main__": @@ -447,7 +448,8 @@ def main( parallel=args.parallel, pyright_stats=True, output_list_only=True, - create_daily=True + create_daily=True, + prioritized=True ) elif args.package_list: main(