Skip to content

pyright

GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

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

pyright - GitHub

Configuration in MegaLinter

Variable Description Default value
PYTHON_PYRIGHT_ARGUMENTS User custom arguments to add in linter CLI call
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 files
Ex: [".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_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 Install in VSCode

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 113 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 81 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 58 Docker Image Size (tag) Docker Pulls

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
  --warnings                         Use exit code of 1 if warnings are reported
  -w,--watch                         Continue to run and watch for changes

Installation on mega-linter Docker image