pyright
Optional static typing checks for python, by Microsoft
If you don't use python static typing, you should disable this linter by adding PYTHON_PYRIGHT
in DISABLE_LINTERS
variable in your .mega-linter.yml
config file
pyright documentation
- Version in MegaLinter: 1.1.353
- Visit Official Web Site
- See How to configure pyright rules
- See How to disable pyright rules in files
- See Index of problems detected by pyright
Configuration in MegaLinter
- Enable pyright by adding
PYTHON_PYRIGHT
in ENABLE_LINTERS variable - Disable pyright by adding
PYTHON_PYRIGHT
in DISABLE_LINTERS variable
Variable | Description | Default value |
---|---|---|
PYTHON_PYRIGHT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
PYTHON_PYRIGHT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
PYTHON_PYRIGHT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
PYTHON_PYRIGHT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
PYTHON_PYRIGHT_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
list_of_files |
PYTHON_PYRIGHT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".py"] |
PYTHON_PYRIGHT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
PYTHON_PYRIGHT_PRE_COMMANDS | List of bash commands to run before the linter | None |
PYTHON_PYRIGHT_POST_COMMANDS | List of bash commands to run after the linter | None |
PYTHON_PYRIGHT_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling PYTHON_PYRIGHT and its pre/post commands | None |
PYTHON_PYRIGHT_CONFIG_FILE | pyright configuration file nameUse LINTER_DEFAULT to let the linter find it |
pyrightconfig.json |
PYTHON_PYRIGHT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
PYTHON_PYRIGHT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
PYTHON_PYRIGHT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
PYTHON_PYRIGHT_CLI_EXECUTABLE | Override CLI executable | ['pyright'] |
IDE Integration
Use pyright in your favorite IDE to catch errors before MegaLinter !
IDE | Extension Name | Install | |
---|---|---|---|
Emacs | LSP-pyright | Visit Web Site | |
Sublime Text | LSP-pyright | Visit Web Site | |
vim | Ale | Visit Web Site | |
vim | coc-pyright | Visit Web Site | |
Visual Studio Code | PyRight |
MegaLinter Flavours
This linter is available in the following flavours
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 121 | ||
cupcake | MegaLinter for the most commonly used languages | 84 | ||
python | Optimized for PYTHON based projects | 62 |
Behind the scenes
How are identified applicable files
- File extensions:
.py
How the linting is performed
- pyright is called once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
pyright myfile.py myfile2.py
pyright myfile.py
Help content
Usage: pyright [options] files...
Options:
--createstub <IMPORT> Create type stub file(s) for import
--dependencies Emit import dependency information
-h,--help Show this help message
--ignoreexternal Ignore external imports for --verifytypes
--level <LEVEL> Minimum diagnostic level (error or warning)
--outputjson Output results in JSON format
-p,--project <FILE OR DIRECTORY> Use the configuration file at this location
--pythonplatform <PLATFORM> Analyze for a specific platform (Darwin, Linux, Windows)
--pythonpath <FILE> Path to the Python interpreter
--pythonversion <VERSION> Analyze for a specific version (3.3, 3.4, etc.)
--skipunannotated Skip analysis of functions with no type annotations
--stats Print detailed performance stats
-t,--typeshedpath <DIRECTORY> Use typeshed type stubs at this location
-v,--venvpath <DIRECTORY> Directory that contains virtual environments
--verbose Emit verbose diagnostics
--verifytypes <PACKAGE> Verify type completeness of a py.typed package
--version Print Pyright version and exit
--warnings Use exit code of 1 if warnings are reported
-w,--watch Continue to run and watch for changes
- Read files from stdin