-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add a stricter config pass for pyright #5612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should document somewhere (not necessarily here) what the "stricter config" is and why it exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where would you suggest? I can leave a comment at the top of the stricter config, or put it somewhere else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of checking a single file?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be useful; I didn't add this instruction though (it was already there). I'll stick something in that readme. |
||
``` | ||
|
||
`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: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make only one of the strict and the lenient run generate comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the first one fails, then it will leave comments and the next step will not run. If the first one passes, then it won't leave any comments and the second one will continue as normal. There shouldn't end up being any duplication.