Pax
Currently, my VS Code doesn't report typing problems until a file is opened in the editor.
I just changed my type-checking mode to something more strict and would like to run pyright against all files without having to manually open each one of them. How do I do this?
Top Answer
Pax
**A workaround** is to install the pyright CLI using [`npm`](https://www.npmjs.com/get-npm)
`npm install --global pyright`
```zsh
-> % pyright
Loading configuration file at /my-project/pyrightconfig.json
Assuming Python version 3.8
Assuming Python platform Darwin
No include entries specified; assuming /my-project
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding .git
stubPath /my-project/typings is not a valid directory.
Searching for source files
Found 64 source files
/my-project/.../service.py
23:31 - error: Cannot access member "subjectLine" for type ...
Member "subjectLine" is unknown (reportGeneralTypeIssues)
/my-project/.../email.py
13:17 - error: Argument of type ... cannot be assigned to parameter "replyTo" of type .. in function "__init__"
... is incompatible with ... (reportGeneralTypeIssues)
23:14 - error: Cannot assign member "_html" for type ..
Expression of type "None" cannot be assigned to member "_html" of class ...
Type "None" cannot be assigned to type "str" (reportGeneralTypeIssues)
...
...
...
```
Since the terminal is already integrated in VS Code, installing the pyright CLI is an option. And because I don't plan to do this regularly, manually running it in the CLI works well.
**Note**
I had to update `node` from 10 to 12 because I was getting an error `Cannot find module 'worker_threads'` when I try to run `pyright`. See [issue](https://github.com/microsoft/pyright/issues/769#issuecomment-650328569).
After updating node, I also installed the latest npm for node 12. I didn't have to reinstall `pyright`. I ran `pyright` again and it worked.
**Within VS Code**
Running linters like `pyright` against all files and having the output display in the "Problems" tab is an ongoing feature request in [vscode-python](https://github.com/Microsoft/vscode-python/issues/3836).
One can [create a task](https://code.visualstudio.com/Docs/editor/tasks) or use extensions like `pucelle.run-on-save` if it is needed to be run regularly; but the raw output is placed in the "Output" tab.