Config settings for gradual adoption #8034
-
Hi! I'm interested in trying out Pyright+Pylance. I'm trying to figure out a plan for gradual adoption in a preexisting codebase; I basically want to set In mypy, I would do something like this in my [mypy]
strict = True
ignore_errors = True
[mypy-util.some_directory.*]
ignore_errors = False
[mypy-backend.models.validation.*]
ignore_errors = False I'm trying to figure out how to achieve a similar setup with Pyright/Pylance. I have a {
"include": [
"backend/models/validation"
],
"pythonVersion": "3.11",
"pythonPlatform": "Linux",
"typeCheckingMode": "standard",
} That config file causes command-line Pyright to behave the way I want, but when editing files in some other directory (eg What should I do differently to cause Pylance and Pyright to both behave the same way (i.e. not report type errors for any directories except the ones listed in my Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I believe that should work except that when you open a file in the IDE, it's automatically included. Open files count towards what we analyze. You could also add an ignore section, but then you get no diagnostics for the
I think what you really want is this enhancement request: microsoft/pylance-release#5564 That way you could have different pyrightconfig.json files at different folders to set the typecheckingmode for each. |
Beta Was this translation helpful? Give feedback.
For general guidance in applying gradual adoption of type checking, refer to this documentation.
If you want to exclude certain files or directories from the project, you can use the
exclude
, but I don't recommend that approach. Instead, I recommend enabling a few diagnostic checks for your entire project, then gradually add diagnostic rules as you fix type issues in your code. If a particular file is too problematic (e.g. contains significant dynamic code), you can explicitly disable specific diagnostic checks for that file using a file-level comment.This is the approach I've used successfully for gradually adopting typing for several large Python code bases.