From 159f6aef5872211da7dc9869f4acaf150c115d86 Mon Sep 17 00:00:00 2001 From: Mohith1612 Date: Fri, 21 Aug 2026 17:34:23 +0530 Subject: [PATCH] Separate Pyright basic and stricter checks --- .github/workflows/tests.yml | 3 +- pyrightconfig.basic.json | 100 ++++++++++++++++++++++++++++++ tests/check_typeshed_structure.py | 13 ++++ 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 pyrightconfig.basic.json diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb8fe504c110..3510c19ef863 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -189,13 +189,14 @@ jobs: run: echo "$PWD/.venv/bin" >> $GITHUB_PATH - name: List 3rd-party stub dependencies installed run: uv pip freeze - - name: Run pyright with basic settings on all the stubs + - name: Run pyright with basic settings on stubs excluded from stricter checks uses: jakebailey/pyright-action@v3 with: version: PATH python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} annotate: ${{ matrix.python-version == '3.13' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy. + project: ./pyrightconfig.basic.json - name: Run pyright with stricter settings on some of the stubs uses: jakebailey/pyright-action@v3 with: diff --git a/pyrightconfig.basic.json b/pyrightconfig.basic.json new file mode 100644 index 000000000000..1459f84dbea7 --- /dev/null +++ b/pyrightconfig.basic.json @@ -0,0 +1,100 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", + "extends": "./pyrightconfig.json", + // Keep in sync with the exclude list in pyrightconfig.stricter.json. + "include": [ + "**/@tests/test_cases", + "stdlib/__main__.pyi", + "stdlib/_operator.pyi", + "stdlib/_tkinter.pyi", + "stdlib/distutils/cmd.pyi", + "stdlib/distutils/command", + "stdlib/distutils/dist.pyi", + "stdlib/encodings/__init__.pyi", + "stdlib/lib2to3/fixes/*.pyi", + "stdlib/numbers.pyi", + "stdlib/operator.pyi", + "stdlib/tkinter/__init__.pyi", + "stdlib/tkinter/dialog.pyi", + "stdlib/tkinter/filedialog.pyi", + "stdlib/tkinter/scrolledtext.pyi", + "stdlib/tkinter/tix.pyi", + "stdlib/tkinter/ttk.pyi", + "stubs/antlr4-python3-runtime", + "stubs/auth0-python", + "stubs/Authlib", + "stubs/aws-xray-sdk", + "stubs/behave", + "stubs/boltons", + "stubs/braintree", + "stubs/cffi", + "stubs/colorful", + "stubs/dateparser", + "stubs/defusedxml", + "stubs/docker", + "stubs/docutils", + "stubs/Flask-SocketIO", + "stubs/gdb", + "stubs/geojson", + "stubs/geopandas", + "stubs/google-cloud-ndb", + "stubs/grpcio-channelz/grpc_channelz/v1", + "stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi", + "stubs/grpcio-reflection/grpc_reflection/v1alpha", + "stubs/grpcio-status/grpc_status", + "stubs/grpcio/grpc/__init__.pyi", + "stubs/gunicorn/gunicorn/dirty", + "stubs/hdbcli/hdbcli/dbapi.pyi", + "stubs/html5lib", + "stubs/httplib2", + "stubs/hvac", + "stubs/jsonschema", + "stubs/jwcrypto", + "stubs/kafka-python", + "stubs/ldap3", + "stubs/m3u8/m3u8/model.pyi", + "stubs/Markdown", + "stubs/mock/mock/mock.pyi", + "stubs/mysqlclient", + "stubs/netaddr/netaddr/core.pyi", + "stubs/netaddr/netaddr/ip/__init__.pyi", + "stubs/netaddr/netaddr/ip/iana.pyi", + "stubs/networkx", + "stubs/oauthlib", + "stubs/openpyxl", + "stubs/opentracing/opentracing/span.pyi", + "stubs/paramiko/paramiko/_winapi.pyi", + "stubs/parsimonious/parsimonious/nodes.pyi", + "stubs/peewee", + "stubs/pexpect", + "stubs/pika/pika/adapters/twisted_connection.pyi", + "stubs/pika/pika/adapters/utils/connection_workflow.pyi", + "stubs/pika/pika/callback.pyi", + "stubs/pika/pika/channel.pyi", + "stubs/pony", + "stubs/protobuf", + "stubs/psutil/psutil/__init__.pyi", + "stubs/psycopg2", + "stubs/punq", + "stubs/pyasn1", + "stubs/pycups", + "stubs/Pygments", + "stubs/PyMySQL", + "stubs/pyogrio", + "stubs/python-jose", + "stubs/pywin32", + "stubs/PyYAML", + "stubs/reportlab", + "stubs/requests", + "stubs/requests-oauthlib", + "stubs/seaborn", + "stubs/setuptools/setuptools", + "stubs/shapely", + "stubs/simple-websocket", + "stubs/tensorflow", + "stubs/tqdm", + "stubs/vobject", + "stubs/workalendar", + "stubs/xmldiff", + ], +} diff --git a/tests/check_typeshed_structure.py b/tests/check_typeshed_structure.py index 8748c80aea5a..b620f56e2626 100755 --- a/tests/check_typeshed_structure.py +++ b/tests/check_typeshed_structure.py @@ -188,6 +188,18 @@ def check_pyright_exclude_order() -> None: ), f"Entry '{exclude[i]}' should come before '{exclude[i + 1]}' in the {PYRIGHT_CONFIG.name} exclude list" +def check_pyright_configs_consistent() -> None: + """Check that basic and stricter Pyright runs cover complementary paths.""" + stricter_config = json.loads(jsonc_to_json(PYRIGHT_CONFIG.read_text(encoding="utf-8"))) + basic_config_path = PYRIGHT_CONFIG.with_name("pyrightconfig.basic.json") + basic_config = json.loads(jsonc_to_json(basic_config_path.read_text(encoding="utf-8"))) + + assert basic_config.get("extends") == "./pyrightconfig.json" + assert basic_config.get("include") == stricter_config.get( + "exclude" + ), f"The include list in {basic_config_path.name} must match the exclude list in {PYRIGHT_CONFIG.name}" + + if __name__ == "__main__": check_versions_file() check_metadata() @@ -198,3 +210,4 @@ def check_pyright_exclude_order() -> None: check_distutils() check_test_cases() check_pyright_exclude_order() + check_pyright_configs_consistent()