Skip to content

Commit b6d56e3

Browse files
committed
Merge remote-tracking branch 'upstream/main' into codex/pr-1916-merge-main
# Conflicts: # conformance/results/mypy/version.toml # conformance/results/pyre/qualifiers_final_decorator.toml # conformance/results/pyre/version.toml # conformance/results/pyright/qualifiers_annotated.toml # conformance/results/pyright/qualifiers_final_decorator.toml # conformance/results/pyright/version.toml # conformance/results/pytype/qualifiers_final_decorator.toml # conformance/results/pytype/version.toml # conformance/results/results.html
2 parents f4d1db6 + 691e9e4 commit b6d56e3

1,138 files changed

Lines changed: 18292 additions & 16509 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/ISSUE_TEMPLATE/documentation-issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Documentation issue
3-
about: Report a problem or suggest changes for the documentation at https://typing.readthedocs.io/
3+
about: Report a problem or suggest changes for the documentation at https://typing.python.org/
44
title: ''
55
labels: 'topic: documentation'
66
assignees: ''

.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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Documentation and Support
44

55
The documentation for Python's static typing can be found at
6-
[typing.readthedocs.io](https://typing.readthedocs.io/). You can get
6+
[typing.python.org](https://typing.python.org/). You can get
77
help in our [support forum](https://github.com/python/typing/discussions).
88

99
Improvements to the type system should be discussed on
@@ -14,16 +14,16 @@ 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

2121
This GitHub repository is used for several things:
2222

23-
- The documentation at [typing.readthedocs.io](https://typing.readthedocs.io/)
23+
- The documentation at [typing.python.org](https://typing.python.org/)
2424
is maintained in the [docs directory](./docs). This includes the
25-
[specification](https://typing.readthedocs.io/en/latest/spec/index.html) for the
26-
type system. See especially [the update procedure](https://typing.readthedocs.io/en/latest/spec/meta.html)
25+
[specification](https://typing.python.org/en/latest/spec/index.html) for the
26+
type system. See especially [the update procedure](https://typing.python.org/en/latest/spec/meta.html)
2727
for the spec.
2828

2929
- A [discussion forum](https://github.com/python/typing/discussions) for typing-related user

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: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22

33
## Motivation
44

5-
[PEP 729](https://peps.python.org/pep-0729/) provides a structured and documented way to specify and evolve the Python type system. In support of this effort, an official [Python typing spec](https://github.com/python/typing/tree/main/docs/spec) has been drafted. This spec consolidates details from various historical typing-related PEPs. The spec will be modified over time to clarify unspecified and under-specified parts of the type system. It will also be extended to cover new features of the type system.
5+
[PEP 729](https://peps.python.org/pep-0729/) provides a structured and documented way to specify and evolve the Python type system. In support of this effort, an official [Python typing spec](https://typing.python.org/en/latest/spec/) has been drafted. This spec consolidates details from various historical typing-related PEPs. The spec will be modified over time to clarify unspecified and under-specified parts of the type system. It will also be extended to cover new features of the type system.
66

77
Accompanying the typing specification is this conformance test suite which validates the behavior of static type checkers against the specification.
88

99
## Structure & Name
1010

1111
This project contains test cases for behaviors defined in the Python typing spec. Tests are structured and grouped in accordance with the specification's chapter headings.
1212

13-
* [concepts](https://typing.readthedocs.io/en/latest/spec/concepts.html)
14-
* [annotations](https://typing.readthedocs.io/en/latest/spec/annotations.html)
15-
* [specialtypes](https://typing.readthedocs.io/en/latest/spec/special-types.html)
16-
* [generics](https://typing.readthedocs.io/en/latest/spec/generics.html)
17-
* [qualifiers](https://typing.readthedocs.io/en/latest/spec/qualifiers.html)
18-
* [classes](https://typing.readthedocs.io/en/latest/spec/class-compat.html)
19-
* [aliases](https://typing.readthedocs.io/en/latest/spec/aliases.html)
20-
* [literals](https://typing.readthedocs.io/en/latest/spec/literal.html)
21-
* [protocols](https://typing.readthedocs.io/en/latest/spec/protocol.html)
22-
* [callables](https://typing.readthedocs.io/en/latest/spec/callables.html)
23-
* [constructors](https://typing.readthedocs.io/en/latest/spec/constructors.html)
24-
* [overloads](https://typing.readthedocs.io/en/latest/spec/overload.html)
25-
* [dataclasses](https://typing.readthedocs.io/en/latest/spec/dataclasses.html)
26-
* [typeddicts](https://typing.readthedocs.io/en/latest/spec/typeddict.html)
27-
* [tuples](https://typing.readthedocs.io/en/latest/spec/tuples.html)
28-
* [namedtuples](https://typing.readthedocs.io/en/latest/spec/namedtuples.html)
29-
* [narrowing](https://typing.readthedocs.io/en/latest/spec/narrowing.html)
30-
* [directives](https://typing.readthedocs.io/en/latest/spec/directives.html)
31-
* [distribution](https://typing.readthedocs.io/en/latest/spec/distributing.html)
32-
* [historical](https://typing.readthedocs.io/en/latest/spec/historical.html)
13+
* [concepts](https://typing.python.org/en/latest/spec/concepts.html)
14+
* [annotations](https://typing.python.org/en/latest/spec/annotations.html)
15+
* [typeforms](https://typing.python.org/en/latest/spec/type-forms.html)
16+
* [specialtypes](https://typing.python.org/en/latest/spec/special-types.html)
17+
* [generics](https://typing.python.org/en/latest/spec/generics.html)
18+
* [qualifiers](https://typing.python.org/en/latest/spec/qualifiers.html)
19+
* [classes](https://typing.python.org/en/latest/spec/class-compat.html)
20+
* [aliases](https://typing.python.org/en/latest/spec/aliases.html)
21+
* [literals](https://typing.python.org/en/latest/spec/literal.html)
22+
* [protocols](https://typing.python.org/en/latest/spec/protocol.html)
23+
* [callables](https://typing.python.org/en/latest/spec/callables.html)
24+
* [constructors](https://typing.python.org/en/latest/spec/constructors.html)
25+
* [overloads](https://typing.python.org/en/latest/spec/overload.html)
26+
* [dataclasses](https://typing.python.org/en/latest/spec/dataclasses.html)
27+
* [typeddicts](https://typing.python.org/en/latest/spec/typeddict.html)
28+
* [tuples](https://typing.python.org/en/latest/spec/tuples.html)
29+
* [namedtuples](https://typing.python.org/en/latest/spec/namedtuples.html)
30+
* [narrowing](https://typing.python.org/en/latest/spec/narrowing.html)
31+
* [directives](https://typing.python.org/en/latest/spec/directives.html)
32+
* [distribution](https://typing.python.org/en/latest/spec/distributing.html)
33+
* [historical](https://typing.python.org/en/latest/spec/historical.html)
3334

3435
A test file is a ".py" file. The file name should start with one of the above names followed by a description of the test (with words separated by underscores). For example, `generics_paramspec_basic_usage.py` would contain the basic usage tests for `ParamSpec`. Each test file can contain multiple individual unit tests, but these tests should be related to each other. If the number of unit tests in a single test file exceeds ten, it may be desirable to split it into separate test files. This will help maintain a consistent level of granularity across tests.
3536

@@ -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

0 commit comments

Comments
 (0)