diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f99e55d27de2..8ba682c0bd66 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,11 +76,20 @@ jobs: python-platform: ["Linux", "Windows", "Darwin"] python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] fail-fast: false + env: + PYRIGHT_VERSION: 1.1.148 # Must match pyright_test.py. steps: - uses: actions/checkout@v2 - uses: jakebailey/pyright-action@v1 with: - version: 1.1.144 # Must match pyright_test.py. + version: ${{ env.PYRIGHT_VERSION }} + python-platform: ${{ matrix.python-platform }} + python-version: ${{ matrix.python-version }} + no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. + project: ./pyrightconfig.stricter.json + - uses: jakebailey/pyright-action@v1 + with: + version: ${{ env.PYRIGHT_VERSION }} python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. diff --git a/pyrightconfig.json b/pyrightconfig.json index b1163e35399c..fcdeaf92bf5e 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -56,7 +56,7 @@ "reportInvalidTypeVarUse": "error", "reportPropertyTypeMismatch": "error", "reportSelfClsParameterName": "error", - // Overloapping overloads cannot be enabled at this time because + // Overlapping overloads cannot be enabled at this time because // of the "factions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy // issue #10143 and #10157). diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json new file mode 100644 index 000000000000..4d84e8dfe92f --- /dev/null +++ b/pyrightconfig.stricter.json @@ -0,0 +1,93 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", + "typeshedPath": ".", + "include": [ + "stdlib", + "stubs" + ], + "exclude": [ + // Python 2 only modules. + "**/@python2", + "stubs/enum34", + "stubs/fb303", + "stubs/futures", + "stubs/ipaddress", + "stubs/kazoo", + "stubs/openssl-python", + "stubs/pathlib2", + "stubs/pymssql", + "stubs/Routes", + "stubs/scribe", + "stubs/tornado", + // Modules that are incomplete in some way. + "stdlib/sqlite3/dbapi2.pyi", + "stdlib/tkinter", + "stdlib/xml/dom", + "stdlib/xml/sax", + "stubs/backports", + "stubs/backports_abc", + "stubs/boto", + "stubs/cryptography", + "stubs/docutils", + "stubs/Flask", + "stubs/Jinja2", + "stubs/Markdown", + "stubs/Pillow", + "stubs/paramiko", + "stubs/protobuf", + "stubs/PyMySQL", + "stubs/python-dateutil", + "stubs/pyvmomi", + "stubs/PyYAML", + "stubs/redis", + "stubs/requests", + "stubs/simplejson", + "stubs/waitress", + "stubs/Werkzeug" + ], + "typeCheckingMode": "basic", + "strictListInference": true, + "strictDictionaryInference": true, + "strictParameterNoneValue": true, + "reportFunctionMemberAccess": "error", + "reportMissingModuleSource": "none", + "reportMissingTypeStubs": "error", + "reportUnusedImport": "error", + "reportUnusedClass": "error", + "reportUnusedFunction": "error", + "reportUnusedVariable": "error", + "reportDuplicateImport": "error", + "reportOptionalSubscript": "error", + "reportOptionalMemberAccess": "error", + "reportOptionalCall": "error", + "reportOptionalIterable": "error", + "reportOptionalContextManager": "error", + "reportOptionalOperand": "error", + "reportUntypedFunctionDecorator": "error", + "reportUntypedClassDecorator": "error", + "reportUntypedBaseClass": "error", + "reportUntypedNamedTuple": "error", + "reportPrivateUsage": "error", + "reportConstantRedefinition": "error", + "reportIncompatibleMethodOverride": "error", + "reportIncompatibleVariableOverride": "error", + "reportInvalidStringEscapeSequence": "error", + "reportUnknownParameterType": "error", + "reportUnknownArgumentType": "error", + "reportUnknownLambdaType": "error", + "reportUnknownVariableType": "error", + "reportUnknownMemberType": "error", + "reportMissingTypeArgument": "error", + "reportUndefinedVariable": "error", + "reportUnboundVariable": "error", + "reportInvalidStubStatement": "error", + "reportUnsupportedDunderAll": "error", + "reportInvalidTypeVarUse": "error", + "reportPropertyTypeMismatch": "error", + "reportSelfClsParameterName": "error", + // Overlapping overloads cannot be enabled at this time because + // of the "factions.Fraction.__pow__" method and "tasks.gather" function. + // Mypy's overlapping overload logic misses these issues (see mypy + // issue #10143 and #10157). + "reportOverlappingOverload": "none" +} diff --git a/tests/README.md b/tests/README.md index 49c6fba51817..a7453ae3aed6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -47,10 +47,15 @@ This test requires [Node.js](https://nodejs.org) to be installed. It is currently not part of the CI, but it uses the same pyright version and configuration as the CI. ``` -(.venv3)$ python3 tests/pyright_test.py # Check all files -(.venv3)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file +(.venv3)$ python3 tests/pyright_test.py # Check all files +(.venv3)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file +(.venv3)$ python3 tests/pyright_test.py -p pyrightconfig.stricter.json # Check with the stricter config. ``` +`pyrightconfig.stricter.json` is a stricter configuration that enables additional +checks that would typically fail on incomplete stubs (such as `Unknown` checks), +and is run on a subset of stubs (including the standard library). + ## check\_consistent.py Run using: diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 415b381d784e..f811a9668b34 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -5,7 +5,7 @@ import sys from pathlib import Path -_PYRIGHT_VERSION = "1.1.144" # Must match tests.yml. +_PYRIGHT_VERSION = "1.1.148" # Must match tests.yml. _WELL_KNOWN_FILE = Path("tests", "pyright_test.py")