Skip to content

Only default to pyright on default page #68

New issue

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 12 additions & 10 deletions analyzer/historical_view_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -139,46 +139,47 @@ 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',
data: {{ records | map(attribute='CoverageData.parameter_coverage_with_stubs') | list | safe }},
borderColor: 'rgb(54, 162, 235)',
yAxisID: 'y1',
tension: 0.1,
hidden: true
hidden: {{ 'true' if prioritized else 'false' }}
},
{
label: 'Return Coverage with Stubs',
data: {{ records | map(attribute='CoverageData.return_type_coverage_with_stubs') | list | safe }},
borderColor: 'rgb(75, 192, 192)',
yAxisID: 'y1',
tension: 0.1,
hidden: true
hidden: {{ 'true' if prioritized else 'false' }}
},
{
label: 'Parameter Coverage',
data: {{ records | map(attribute='CoverageData.parameter_coverage') | list | safe }},
borderColor: 'rgb(153, 102, 255)',
yAxisID: 'y1',
tension: 0.1,
hidden: true
hidden: true
},
{
label: 'Return Coverage',
data: {{ records | map(attribute='CoverageData.return_type_coverage') | list | safe }},
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' }}
}
]
},
Expand Down Expand Up @@ -235,13 +236,14 @@ def generate_html(historical_data: Dict[str, List[Dict[str, Any]]], html_output:
</html>
"""
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)
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}

Expand Down Expand Up @@ -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__":
Expand Down Expand Up @@ -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(
Expand Down