Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ jobs:
- uses: actions/setup-python@v2
- run: ./tests/mypy_test_suite.py

pyright:
name: Run pyright against the stubs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: ./tests/pyright_test.py

stubtest:
name: Check stdlib with stubtest
runs-on: ${{ matrix.os }}
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ There are several tests:
tests typeshed with [mypy](https://github.com/python/mypy/)
- `tests/pytype_test.py` tests typeshed with
[pytype](https://github.com/google/pytype/).
- `tests/pyright_test.py` tests typeshed with
[pyright](https://github.com/microsoft/pyright).
- `tests/mypy_self_check.py` checks mypy's code base using this version of
typeshed.
- `tests/mypy_test_suite.py` runs a subset of mypy's test suite using this version of
Expand All @@ -121,14 +123,17 @@ consistent with each other.

Run:
```
$ python3.6 -m venv .venv3
$ python3 -m venv .venv3
$ source .venv3/bin/activate
(.venv3)$ pip install -U pip
(.venv3)$ pip install -r requirements-tests-py3.txt
```
This will install mypy (you need the latest master branch from GitHub),
typed-ast, flake8 (and plugins), pytype, black and isort.

If you want to run the pyright tests, you need to have
[Node.js](https://nodejs.org/) installed.

### mypy_test.py

This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Expand Down Expand Up @@ -160,6 +165,10 @@ Run using: `(.venv3)$ python3 tests/pytype_test.py`

This test works similarly to `mypy_test.py`, except it uses `pytype`.

### pyright\_test.py

This test requires Node.js to be installed.

### mypy_self_check.py

This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Expand Down
94 changes: 94 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"typeshedPath": ".",
"include": [
"stdlib",
"stubs"
],
"exclude": [
"**/@python2",
"stdlib/encodings/__init__.pyi",
"stdlib/sqlite3/dbapi2.pyi",
"stdlib/tkinter",
"stdlib/xml/dom",
"stdlib/xml/sax",
"stubs/backports",
"stubs/backports_abc",
"stubs/boto",
"stubs/cachetools",
"stubs/chardet",
"stubs/click",
"stubs/cryptography",
"stubs/dateparser",
"stubs/DateTimeRange",
"stubs/decorator",
"stubs/docutils",
"stubs/fb303",
"stubs/Flask",
"stubs/frozendict",
"stubs/Jinja2",
"stubs/kazoo",
"stubs/Markdown",
"stubs/MarkupSafe",
"stubs/mock",
"stubs/nmap",
"stubs/openssl-python",
"stubs/polib",
"stubs/paramiko",
"stubs/protobuf",
"stubs/pymssql",
"stubs/PyMySQL",
"stubs/python-dateutil",
"stubs/pyvmomi",
"stubs/PyYAML",
"stubs/redis",
"stubs/requests",
"stubs/Routes",
"stubs/scribe",
"stubs/simplejson",
"stubs/tornado",
"stubs/waitress",
"stubs/Werkzeug"
],
"pythonVersion": "3.9",
"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": "none",
"reportOverlappingOverload": "none",
"reportPropertyTypeMismatch": "none",
"reportSelfClsParameterName": "none"
}
3 changes: 3 additions & 0 deletions tests/pyright_exclude_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pyright is configured using a "pyrightconfig.json" file. You will find
it at the root of the repo. It contains an "exclude" section that accepts
globs for specifying which files and/or directories to exclude from analysis.
30 changes: 30 additions & 0 deletions tests/pyright_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import subprocess
import sys
from pathlib import Path


_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
_PYRIGHT_COMMAND = ["npx", "-p", "pyright@1.1.114", "pyright"]


def main() -> None:
assert_npm_is_installed()
ret = subprocess.run(_PYRIGHT_COMMAND).returncode
sys.exit(ret)


def assert_npm_is_installed() -> None:
if not _WELL_KNOWN_FILE.exists():
print("pyright_test.py must be run from the typeshed root directory", file=sys.stderr)
sys.exit(1)
try:
subprocess.run(["npx", "--version"])
except OSError:
print("error running npx; is Node.js installed?", file=sys.stderr)
sys.exit(1)


if __name__ == "__main__":
main()