Skip to content

Commit c341ec3

Browse files
Merge branch 'main' into delete_typeddict_kwargs_passing
2 parents 81f2150 + 691e9e4 commit c341ec3

1,133 files changed

Lines changed: 16813 additions & 17125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
conformance/results/results.html linguist-generated

.github/workflows/build-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v7
1717
- name: Set up Python
18-
uses: actions/setup-python@v5
18+
uses: actions/setup-python@v7
1919
with:
20-
python-version: 3.9
20+
python-version: "3.14"
2121
- name: Install dependencies
2222
run: |
2323
pip install --upgrade pip
24-
pip install -r docs/requirements.txt
24+
pip install --group docs
2525
- name: Build the documentation
2626
run: make -C docs html

.github/workflows/ci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
18-
- name: Set up Python 3
19-
uses: actions/setup-python@v5
17+
- uses: actions/checkout@v7
18+
- uses: actions/setup-python@v7
2019
with:
21-
python-version: 3
20+
python-version: "3.14"
2221
cache: "pip"
23-
cache-dependency-path: "test-requirements.txt"
2422

2523
- name: Install dependencies
2624
run: |
2725
pip install --upgrade pip
28-
pip install -r test-requirements.txt
26+
pip install --group test
2927
3028
- name: Lint implementation
3129
run: flake8

.github/workflows/conformance.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Conformance
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
conformance:
12+
name: Run conformance suite
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v7
17+
18+
- name: Set up Python 3.12
19+
uses: actions/setup-python@v7
20+
with:
21+
python-version: "3.12"
22+
cache: "pip"
23+
24+
- name: Install uv
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install uv
28+
29+
- name: Run conformance suite
30+
working-directory: conformance
31+
run: |
32+
uv sync --python 3.12 --frozen
33+
uv run --python 3.12 --frozen python src/main.py
34+
35+
- name: Validate conformance invariants
36+
working-directory: conformance
37+
run: |
38+
uv run --python 3.12 --frozen python src/validate_results.py
39+
40+
- name: Assert conformance results are up to date
41+
run: |
42+
if [ -n "$(git status --porcelain -- conformance/results)" ]; then
43+
git status --short conformance/results
44+
git diff -- conformance/results
45+
echo "Conformance results are out of date. Run conformance/src/main.py and commit updated results."
46+
exit 1
47+
fi

.readthedocs.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
version: 2
55

66
build:
7-
os: ubuntu-22.04
7+
os: ubuntu-26.04
88
tools:
99
python: "3"
10+
jobs:
11+
install:
12+
- uv sync --group docs
1013

1114
sphinx:
1215
configuration: docs/conf.py
1316

1417
python:
1518
install:
16-
- requirements: docs/requirements.txt
19+
- method: uv
20+
command: sync

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repository.
1414
For conversations that are more suitable to a chat platform, you can use one of the following:
1515

1616
- [gitter](https://gitter.im/python/typing)
17-
- [discord](https://discord.com/channels/267624335836053506/891788761371906108) `#type-hinting` channel
17+
- [discord](https://discord.com/invite/python) [#type-hinting](https://discord.com/channels/267624335836053506/891788761371906108) channel
1818

1919
## Repository Content
2020

conformance/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ MANIFEST
3232

3333
# Tools
3434
.mypy_cache
35-
.pyre_configuration
36-
.pyre
3735
.coverage
3836
htmlcov
3937

conformance/README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project contains test cases for behaviors defined in the Python typing spec
1212

1313
* [concepts](https://typing.python.org/en/latest/spec/concepts.html)
1414
* [annotations](https://typing.python.org/en/latest/spec/annotations.html)
15+
* [typeforms](https://typing.python.org/en/latest/spec/type-forms.html)
1516
* [specialtypes](https://typing.python.org/en/latest/spec/special-types.html)
1617
* [generics](https://typing.python.org/en/latest/spec/generics.html)
1718
* [qualifiers](https://typing.python.org/en/latest/spec/qualifiers.html)
@@ -46,27 +47,41 @@ Test cases use the following conventions:
4647
* Lines that are expected to produce a type checker error should have a comment starting with # E",
4748
either by itself or followed by an explanation after a colon (e.g., "# E: int is not a subtype
4849
of str"). Such explanatory comments are purely for human understanding, but type checkers are not
49-
expected to use their exact wording.
50+
expected to use their exact wording. There are several syntactic variations; see "Test Case Syntax"
51+
below.
5052
* Lines that may produce an error (e.g., because the spec allows multiple behaviors) should be
5153
marked with "# E?" instead of "# E".
5254
* If a test case tests conformance with a specific passage in the spec, that passage should be
5355
quoted in a comment prefixed with "# > ".
5456

57+
## Test Case Syntax
58+
59+
Test cases support the following special comments for declaring where errors should be raised:
60+
61+
* `# E`: an error must be raised on this line
62+
* `# E?`: an error may be raised on this line
63+
* `# E[tag]`, where `tag` is an arbitrary string: must appear multiple times in a file with the same tag.
64+
Exactly one line with this tag must raise an error.
65+
* `# E[tag+]`: like `# E[tag]`, but errors may be raised on multiple lines.
66+
67+
Each comment may be followed by a colon plus an explanation of the error; the explanation is ignored
68+
by the scoring system.
69+
5570
## Running the Conformance Test Tool
5671

5772
To run the conformance test suite:
5873
* Clone the https://github.com/python/typing repo.
59-
* Create and activate a Python 3.12 virtual environment.
60-
* Switch to the `conformance` subdirectory and install all dependencies (`pip install -r requirements.txt`).
61-
* Switch to the `src` subdirectory and run `python main.py`.
74+
* Install [uv](https://docs.astral.sh/uv/) and ensure Python 3.12 is available.
75+
* Switch to the `conformance` subdirectory and install locked dependencies (`uv sync --python 3.12 --frozen`).
76+
* Run the conformance tool (`uv run --python 3.12 --frozen python src/main.py`).
6277

63-
Note that some type checkers may not run on some platforms. For example, pytype cannot be installed on Windows. If a type checker fails to install, tests will be skipped for that type checker.
78+
Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker.
6479

6580
## Reporting Conformance Results
6681

6782
Different type checkers report errors in different ways (with different wording in error messages and different line numbers or character ranges for errors). This variation makes it difficult to fully automate test validation given that tests will want to check for both false positive and false negative type errors. Some level of manual inspection will therefore be needed to determine whether a type checker is fully conformant with all tests in any given test file. This "scoring" process is required only when the output of a test changes — e.g. when a new version of that type checker is released and the tests are rerun. We assume that the output of a type checker will be the same from one run to the next unless/until a new version is released that fixes or introduces a bug. In this case, the output will need to be manually inspected and the conformance results re-scored for those tests whose output has changed.
6883

69-
Conformance results are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyre, pyright, and pytype. It is the goal and desire to add additional type checkers over time.
84+
[Conformance results](https://htmlpreview.github.io/?https://github.com/python/typing/blob/main/conformance/results/results.html) are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyrefly, pyright, zuban, ty, and pycroscope. It is the goal and desire to add additional type checkers over time.
7085

7186
## Adding a New Test Case
7287

@@ -78,7 +93,22 @@ If a test is updated (augmented or fixed), the process is similar to when adding
7893

7994
## Updating a Type Checker
8095

81-
If a new version of a type checker is released, re-run the test tool with the new version. If the type checker output has changed for any test cases, the tool will supply the old and new outputs. Examine these to determine whether the conformance status has changed. Once the conformance status has been updated, re-run the test tool again to regenerate the summary report.
96+
Type checker versions are locked in `uv.lock`.
97+
98+
To bump all supported checkers to their latest released versions:
99+
100+
```bash
101+
python scripts/bump_type_checkers.py
102+
```
103+
104+
After bumping, install the new lockfile and rerun conformance:
105+
106+
```bash
107+
uv sync --python 3.12 --frozen
108+
uv run --python 3.12 --frozen python src/main.py
109+
```
110+
111+
If checker output changes for any test cases, examine those deltas to determine whether the conformance status has changed. Once the conformance status has been updated, rerun the tool to regenerate the summary report.
82112

83113
## Automated Conformance Checking
84114

conformance/pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[project]
2+
name = "typing-conformance"
3+
version = "0.1.0"
4+
requires-python = "==3.12.*"
5+
dependencies = [
6+
"jinja2",
7+
"markdown",
8+
"mypy",
9+
"pycroscope",
10+
"pyrefly==1.3.0.dev1",
11+
"pyright",
12+
"tomlkit",
13+
"ty",
14+
"types-markdown",
15+
"zuban",
16+
]
17+
18+
[tool.uv]
19+
package = false

conformance/requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)