8000 Initial check-in of type specification conformance suite. by erictraut · Pull Request #1552 · python/typing · GitHub
[go: up one dir, main page]

Skip to content

Initial check-in of type specification conformance suite. #1552

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

Merged
merged 19 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9a94ef
Initial check-in of type specification conformance suite.
erictraut Dec 26, 2023
2f565e5
Fixed syntax error in f-string that affects 3.11 and older.
erictraut Dec 26, 2023
815ec19
Addressed PR feedback. Addressed linter issues.
erictraut Dec 26, 2023
b35bfa9
Updated test results for pyright 1.1.343, which addresses all conform…
erictraut Dec 26, 2023
89d41d3
Added support for pytest.
erictraut Dec 26, 2023
448fffe
Improved report visuals. Added timing stats.
erictraut Dec 26, 2023
4b9ec56
Incorporated PR feedback: use `{sys.executable} -m` for `run` invocat…
erictraut Dec 26, 2023
f89c985
Switched from "Yes" to "Pass" for clarity. Started to add dataclass t…
erictraut Dec 26, 2023
e057706
Added more dataclass tests.
erictraut Dec 27, 2023
e696bed
Added more dataclass tests.
erictraut Dec 27, 2023
3f4eb6d
Added tests for dataclass_transform.
erictraut Dec 27, 2023
c797202
Added some tests for callables.
erictraut Dec 27, 2023
3ec7eff
Added test for `**kwargs` with Unpack TypedDict annotation.
erictraut Dec 27, 2023
f4a0c96
Started to add tests for type aliases.
erictraut Dec 27, 2023
31985ba
Renamed "traditional" to "implicit" for clarity.
erictraut Dec 27, 2023
560791c
Added tests for explicit type aliases, recursive type aliases, and Ne…
erictraut Dec 27, 2023
5e10e0b
Added tests for Python 3.12 `type` statement to define type aliases.
erictraut Dec 28, 2023
ca01411
Added tests for TypeAliasType.
erictraut Dec 28, 2023
cc3fb5a
Added code to skip tests for a type checker if it cannot be installed…
erictraut Dec 28, 2023
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
Prev Previous commit
Next Next commit
Improved report visuals. Added timing stats.
  • Loading branch information
erictraut committed Dec 26, 2023
commit 448fffed2ea58b14863e03576d887078ea97967c
1 change: 1 addition & 0 deletions conformance/results/mypy/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "mypy 1.8.0"
test_duration = 0.31742215156555176
1 change: 1 addition & 0 deletions conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
8000 version = "pyre 0.9.19"
test_duration = 1.2770380973815918
1 change: 1 addition & 0 deletions conformance/results/pyright/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "pyright 1.1.343"
test_duration = 0.7825243473052979
1 change: 1 addition & 0 deletions conformance/results/pytype/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "pytype 2023.12.18"
test_duration = 18.681317806243896
83 changes: 54 additions & 29 deletions conformance/results/results.html

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions conformance/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from pathlib import Path
import sys
from time import time
from typing import Sequence

import tomli
Expand All @@ -21,15 +22,19 @@ def run_tests(
test_cases: Sequence[Path],
):
print(f"Running tests for {type_checker.name}")

test_start_time = time()
tests_output = type_checker.run_tests([file.name for file in test_cases])
test_duration = time() - test_start_time

results_dir = root_dir / "results" / type_checker.name

for test_case in test_cases:
update_output_for_test(
type_checker, results_dir, test_case, tests_output.get(test_case.name, "")
)

update_type_checker_version(type_checker, root_dir)
update_type_checker_info(type_checker, root_dir, test_duration)


def update_output_for_test(
Expand Down Expand Up @@ -74,7 +79,7 @@ def update_output_for_test(
tomlkit.dump(existing_results, f)


def update_type_checker_version(type_checker: TypeChecker, root_dir: Path):
def update_type_checker_info(type_checker: TypeChecker, root_dir: Path, test_duration: float):
# Record the version of the type checker used for the latest run.
version_file = root_dir / "results" / type_checker.name / "version.toml"

Expand All @@ -86,6 +91,7 @@ def update_type_checker_version(type_checker: TypeChecker, root_dir: Path):
existing_info = {}

existing_info["version"] = type_checker.get_version()
existing_info["test_duration"] = test_duration

version_file.parent.mkdir(parents=True, exist_ok=True)
with open(version_file, "w") as f:
Expand Down
11 changes: 8 additions & 3 deletions conformance/src/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ def generate_summary_html(root_dir: Path):
existing_info = {}

version = existing_info["version"] or "Unknown version"
test_duration = existing_info.get("test_duration")

summary_html += f"<div><h4>{version}</h4></div>\n"
summary_html += f"<div class='tc-header'><span class='tc-name'>{version}"
if test_duration is not None:
summary_html += f"<span class='tc-time'>({test_duration:.2f}sec)</span>\n"
summary_html += '</div>\n'
summary_html += '<div class="table_container"><table>\n'
summary_html += '<tr><th class="column spacer" colspan="4"></th></tr>\n'

for test_group_name, test_group in test_groups.items():
tests_in_group = [
Expand Down Expand Up @@ -91,8 +96,8 @@ def generate_summary_html(root_dir: Path):
summary_html += f'<th class="column col2 {conformance_class}">{conformance}</th>'
summary_html += f'<th class="column col3">{notes}</th></tr>\n'

# Add a spacer row after this group to help with readability.
summary_html += '<tr><th class="column" colspan="4"></th></tr>\n'
# Add spacer row after this group to help with readability.
summary_html += '<tr><th class="column spacer" colspan="4"></th></tr>\n'

summary_html += "</table></div>\n"

Expand Down
27 changes: 22 additions & 5 deletions conformance/src/results_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
font-weight: normal;
}

th {
background-color: #f8f8f8;
}

.content_container {
margin: 20px;
}
Expand All @@ -57,7 +53,6 @@
}

.column {
background-color: #f8f8f8;
padding-left: 8px;
padding-right: 8px;
padding-top: 4px;
Expand All @@ -71,6 +66,12 @@
border: 0px solid #000;
}

.spacer {
border-color: #f0f0f0;
border-style: solid;
border-bottom-width: 1px;
}

.col1 {
width: 25%;
vertical-align: top;
Expand All @@ -86,6 +87,22 @@
vertical-align: top;
}

.tc-header {
margin-top: 20px;
margin-bottom: 8px;
}

.tc-name {
font-size: 18px;
font-weight: bold;
}

.tc-time {
margin-left: 8px;
font-size: 12px;
font-weight: normal;
}

.test_group {
font-size: 10pt;
font-weight: bold;
Expand Down
0