Skip to content

Commit 159f6ae

Browse files
committed
Separate Pyright basic and stricter checks
1 parent 8a3c451 commit 159f6ae

3 files changed

Lines changed: 115 additions & 1 deletion

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ jobs:
189189
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
190190
- name: List 3rd-party stub dependencies installed
191191
run: uv pip freeze
192-
- name: Run pyright with basic settings on all the stubs
192+
- name: Run pyright with basic settings on stubs excluded from stricter checks
193193
uses: jakebailey/pyright-action@v3
194194
with:
195195
version: PATH
196196
python-platform: ${{ matrix.python-platform }}
197197
python-version: ${{ matrix.python-version }}
198198
annotate: ${{ matrix.python-version == '3.13' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
199+
project: ./pyrightconfig.basic.json
199200
- name: Run pyright with stricter settings on some of the stubs
200201
uses: jakebailey/pyright-action@v3
201202
with:

pyrightconfig.basic.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
3+
"extends": "./pyrightconfig.json",
4+
// Keep in sync with the exclude list in pyrightconfig.stricter.json.
5+
"include": [
6+
"**/@tests/test_cases",
7+
"stdlib/__main__.pyi",
8+
"stdlib/_operator.pyi",
9+
"stdlib/_tkinter.pyi",
10+
"stdlib/distutils/cmd.pyi",
11+
"stdlib/distutils/command",
12+
"stdlib/distutils/dist.pyi",
13+
"stdlib/encodings/__init__.pyi",
14+
"stdlib/lib2to3/fixes/*.pyi",
15+
"stdlib/numbers.pyi",
16+
"stdlib/operator.pyi",
17+
"stdlib/tkinter/__init__.pyi",
18+
"stdlib/tkinter/dialog.pyi",
19+
"stdlib/tkinter/filedialog.pyi",
20+
"stdlib/tkinter/scrolledtext.pyi",
21+
"stdlib/tkinter/tix.pyi",
22+
"stdlib/tkinter/ttk.pyi",
23+
"stubs/antlr4-python3-runtime",
24+
"stubs/auth0-python",
25+
"stubs/Authlib",
26+
"stubs/aws-xray-sdk",
27+
"stubs/behave",
28+
"stubs/boltons",
29+
"stubs/braintree",
30+
"stubs/cffi",
31+
"stubs/colorful",
32+
"stubs/dateparser",
33+
"stubs/defusedxml",
34+
"stubs/docker",
35+
"stubs/docutils",
36+
"stubs/Flask-SocketIO",
37+
"stubs/gdb",
38+
"stubs/geojson",
39+
"stubs/geopandas",
40+
"stubs/google-cloud-ndb",
41+
"stubs/grpcio-channelz/grpc_channelz/v1",
42+
"stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi",
43+
"stubs/grpcio-reflection/grpc_reflection/v1alpha",
44+
"stubs/grpcio-status/grpc_status",
45+
"stubs/grpcio/grpc/__init__.pyi",
46+
"stubs/gunicorn/gunicorn/dirty",
47+
"stubs/hdbcli/hdbcli/dbapi.pyi",
48+
"stubs/html5lib",
49+
"stubs/httplib2",
50+
"stubs/hvac",
51+
"stubs/jsonschema",
52+
"stubs/jwcrypto",
53+
"stubs/kafka-python",
54+
"stubs/ldap3",
55+
"stubs/m3u8/m3u8/model.pyi",
56+
"stubs/Markdown",
57+
"stubs/mock/mock/mock.pyi",
58+
"stubs/mysqlclient",
59+
"stubs/netaddr/netaddr/core.pyi",
60+
"stubs/netaddr/netaddr/ip/__init__.pyi",
61+
"stubs/netaddr/netaddr/ip/iana.pyi",
62+
"stubs/networkx",
63+
"stubs/oauthlib",
64+
"stubs/openpyxl",
65+
"stubs/opentracing/opentracing/span.pyi",
66+
"stubs/paramiko/paramiko/_winapi.pyi",
67+
"stubs/parsimonious/parsimonious/nodes.pyi",
68+
"stubs/peewee",
69+
"stubs/pexpect",
70+
"stubs/pika/pika/adapters/twisted_connection.pyi",
71+
"stubs/pika/pika/adapters/utils/connection_workflow.pyi",
72+
"stubs/pika/pika/callback.pyi",
73+
"stubs/pika/pika/channel.pyi",
74+
"stubs/pony",
75+
"stubs/protobuf",
76+
"stubs/psutil/psutil/__init__.pyi",
77+
"stubs/psycopg2",
78+
"stubs/punq",
79+
"stubs/pyasn1",
80+
"stubs/pycups",
81+
"stubs/Pygments",
82+
"stubs/PyMySQL",
83+
"stubs/pyogrio",
84+
"stubs/python-jose",
85+
"stubs/pywin32",
86+
"stubs/PyYAML",
87+
"stubs/reportlab",
88+
"stubs/requests",
89+
"stubs/requests-oauthlib",
90+
"stubs/seaborn",
91+
"stubs/setuptools/setuptools",
92+
"stubs/shapely",
93+
"stubs/simple-websocket",
94+
"stubs/tensorflow",
95+
"stubs/tqdm",
96+
"stubs/vobject",
97+
"stubs/workalendar",
98+
"stubs/xmldiff",
99+
],
100+
}

tests/check_typeshed_structure.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ def check_pyright_exclude_order() -> None:
188188
), f"Entry '{exclude[i]}' should come before '{exclude[i + 1]}' in the {PYRIGHT_CONFIG.name} exclude list"
189189

190190

191+
def check_pyright_configs_consistent() -> None:
192+
"""Check that basic and stricter Pyright runs cover complementary paths."""
193+
stricter_config = json.loads(jsonc_to_json(PYRIGHT_CONFIG.read_text(encoding="utf-8")))
194+
basic_config_path = PYRIGHT_CONFIG.with_name("pyrightconfig.basic.json")
195+
basic_config = json.loads(jsonc_to_json(basic_config_path.read_text(encoding="utf-8")))
196+
197+
assert basic_config.get("extends") == "./pyrightconfig.json"
198+
assert basic_config.get("include") == stricter_config.get(
199+
"exclude"
200+
), f"The include list in {basic_config_path.name} must match the exclude list in {PYRIGHT_CONFIG.name}"
201+
202+
191203
if __name__ == "__main__":
192204
check_versions_file()
193205
check_metadata()
@@ -198,3 +210,4 @@ def check_pyright_exclude_order() -> None:
198210
check_distutils()
199211
check_test_cases()
200212
check_pyright_exclude_order()
213+
check_pyright_configs_consistent()

0 commit comments

Comments
 (0)