pyright

Command line wrapper for pyright

MIT 205 个版本 Python >=3.7
Robert Craigie
安装
pip install pyright
poetry add pyright
pipenv install pyright
conda install pyright
描述

Pyright for Python

Downloads PyPI Supported python versions

This project is not affiliated with Microsoft in any way, shape, or form

Pyright for Python is a Python command-line wrapper over pyright, a static type checker for Python.

Installation

Use the package manager pip to install pyright.

pip install pyright

[!TIP] It's highly recommended to install pyright with the nodejs extra which uses nodejs-wheel to download Node.js binaries as it is more reliable than the default nodeenv solution.

pip install pyright[nodejs]

Usage

Pyright can be invoked using two different methods

pyright --help

or

python3 -m pyright --help

Pyright for Python should work exactly the same as pyright does, see the pyright documentation for details on how to make use of pyright.

Pre-commit

You can also setup pyright to run automatically before each commit by setting up pre-commit and registering pyright in your .pre-commit-config.yaml file

repos:
  - repo: https://github.com/RobertCraigie/pyright-python
    rev: v1.1.410
    hooks:
    - id: pyright

Pre-commit will install pyright-python in its own virtual environment which can cause pyright to not be able to detect your installed dependencies.

To fix this you can either tell pre-commit to also install those dependencies or explicitly tell pyright which virtual environment to use by updating your pyright configuration file:

[tool.pyright]
# ...
venvPath = "."
venv = ".venv"

Motivation

Pyright is written in TypeScript, requiring node to be installed, and is normally installed with npm. This could be an entry barrier for some Python developers as they may not have node or npm installed on their machine; I wanted to make pyright as easy to install as any normal Python package.

How Pyright for Python Works

This project works by first checking if node is in the PATH. If it is not, then we download node at runtime using nodeenv, then install the pyright npm package using npm and finally, run the downloaded JS with node.

Automatically keeping pyright up to date

By default Pyright for Python is set to target a specific pyright version and new releases will be automatically created whenever a new pyright version is released. It is highly recommended to use an automatic dependency update tool such as dependabot.

If you would rather not have to update your installation every time a new pyright release is created then you can automatically use the latest available pyright version by setting the environment variable PYRIGHT_PYTHON_FORCE_VERSION to latest.

Configuration

You can configure Pyright for Python using environment variables.

Debugging

Set PYRIGHT_PYTHON_DEBUG to any value.

Modify Pyright Version

Set PYRIGHT_PYTHON_FORCE_VERSION to the desired version, e.g. 1.1.156, latest

Keeping Pyright and Pylance in sync

Set PYRIGHT_PYTHON_PYLANCE_VERSION to your Pylance version, e.g. 2023.11.11, latest-release, latest-prerelease. The corresponding Pyright version will be used. See Pylance's changelog for details on recent releases. Note that PYRIGHT_PYTHON_FORCE_VERSION takes precedence over PYRIGHT_PYTHON_PYLANCE_VERSION, so you'll want to set one or the other, not both.

Show NPM logs

By default, Pyright for Python disables npm error messages, if you want to display the npm error messages then set PYRIGHT_PYTHON_VERBOSE to any truthy value.

Modify NPM Package Location

Pyright for Python will resolve the root cache directory by checking the following environment variables, in order:

  • PYRIGHT_PYTHON_CACHE_DIR
  • XDG_CACHE_HOME

If neither of them are set it defaults to ~/.cache

Force Node Env

Set PYRIGHT_PYTHON_GLOBAL_NODE to any non-truthy value, i.e. anything apart from 1, t, on, or true. e.g. off You can optionally choose the version of node used by setting PYRIGHT_PYTHON_NODE_VERSION to the desired version

Modify Node Env Location

Set PYRIGHT_PYTHON_ENV_DIR to a valid nodeenv directory. e.g. ~/.cache/nodeenv

Ignore Warnings

Set PYRIGHT_PYTHON_IGNORE_WARNINGS to a truthy value, e.g. 1, t, on, or true.

Pyright for Python will print warnings for the following case(s)

  • There is a new Pyright version available.

Contributing

All pull requests are welcome.

License

MIT

版本列表
1.1.410 2026-06-01
1.1.409 2026-04-23
1.1.408 2026-01-08
1.1.407 2025-10-24
1.1.406 2025-10-02
1.1.405 2025-09-04
1.1.404 2025-08-20
1.1.403 2025-07-09
1.1.402 2025-06-11
1.1.401 2025-05-21
1.1.400 2025-04-24
1.1.399 2025-04-10
1.1.398 2025-03-26
1.1.397 2025-03-19
1.1.396 2025-03-02
1.1.395 2025-02-27
1.1.394 2025-02-12
1.1.393 2025-01-29
1.1.392 2025-01-15
1.1.392.post0 2025-01-15
1.1.391 2024-12-18
1.1.390 2024-12-04
1.1.389 2024-11-13
1.1.388 2024-11-06
1.1.387 2024-10-30
1.1.386 2024-10-23
1.1.385 2024-10-16
1.1.384 2024-10-09
1.1.383 2024-10-02
1.1.382 2024-09-25
1.1.382.post1 2024-09-27
1.1.382.post0 2024-09-25
1.1.381 2024-09-18
1.1.380 2024-09-11
1.1.379 2024-09-04
1.1.378 2024-08-28
1.1.377 2024-08-21
1.1.376 2024-08-14
1.1.375 2024-08-07
1.1.374 2024-07-31
1.1.373 2024-07-24
1.1.372 2024-07-17
1.1.371 2024-07-10
1.1.370 2024-07-03
1.1.369 2024-06-25
1.1.368 2024-06-19
1.1.367 2024-06-12
1.1.366 2024-06-05
1.1.365 2024-05-29
1.1.364 2024-05-22
1.1.363 2024-05-15
1.1.362 2024-05-08
1.1.361 2024-05-01
1.1.360 2024-04-24
1.1.359 2024-04-17
1.1.358 2024-04-10
1.1.357 2024-04-03
1.1.356 2024-03-27
1.1.355 2024-03-20
1.1.354 2024-03-13
1.1.353 2024-03-08
1.1.352 2024-02-29
1.1.351 2024-02-19
1.1.350 2024-02-05
1.1.349 2024-01-29
1.1.348 2024-01-21
1.1.347 2024-01-15
1.1.346 2024-01-15
1.1.345 2024-01-08
1.1.344 2023-12-30
1.1.343 2023-12-26
1.1.342 2023-12-20
1.1.341 2023-12-15
1.1.340 2023-12-13
1.1.339 2023-12-06
1.1.338 2023-11-29
1.1.337 2023-11-22
1.1.336 2023-11-15
1.1.335 2023-11-08
1.1.334 2023-11-02
1.1.333 2023-10-25
1.1.332 2023-10-18
1.1.331 2023-10-11
1.1.330 2023-10-07
1.1.330.post0 2023-10-07
1.1.329 2023-09-27
1.1.328 2023-09-26
1.1.327 2023-09-14
1.1.326 2023-09-07
1.1.325 2023-08-30
1.1.324 2023-08-23
1.1.323 2023-08-16
1.1.322 2023-08-12
1.1.321 2023-08-09
1.1.320 2023-08-02
1.1.318 2023-07-21
1.1.317 2023-07-12
1.1.316 2023-06-26
1.1.315 2023-06-21
1.1.314 2023-06-14
1.1.313 2023-06-07
1.1.312 2023-06-07
1.1.311 2023-05-31
1.1.310 2023-05-25
1.1.309 2023-05-18
1.1.308 2023-05-12
1.1.307 2023-05-10
1.1.306 2023-05-03
1.1.305 2023-04-27
1.1.304 2023-04-20
1.1.303 2023-04-14
1.1.302 2023-04-05
1.1.301 2023-03-29
1.1.300 2023-03-22
1.1.299 2023-03-15
1.1.298 2023-03-08
1.1.297 2023-03-08
1.1.296 2023-02-28
1.1.295 2023-02-22
1.1.294 2023-02-15
1.1.293 2023-02-08
1.1.292 2023-02-01
1.1.291 2023-01-25
1.1.290 2023-01-18
1.1.289 2023-01-14
1.1.288 2023-01-11
1.1.287 2023-01-04
1.1.286 2022-12-28
1.1.285 2022-12-21
1.1.284 2022-12-14
1.1.283 2022-12-07
1.1.282 2022-11-30
1.1.281 2022-11-23
1.1.280 2022-11-16
1.1.279 2022-11-09
1.1.278 2022-11-02
1.1.277 2022-10-26
1.1.276 2022-10-19
1.1.275 2022-10-12
1.1.274 2022-10-05
1.1.273 2022-09-28
1.1.272 2022-09-21
1.1.271 2022-09-14
1.1.270 2022-09-07
1.1.269 2022-08-31
1.1.268 2022-08-24
1.1.267 2022-08-17
1.1.266 2022-08-08
1.1.265 2022-08-03
1.1.264 2022-07-27
1.1.263 2022-07-23
1.1.262 2022-07-20
1.1.261 2022-07-16
1.1.260 2022-07-13
1.1.259 2022-07-13
1.1.258 2022-07-09
1.1.257 2022-07-03
1.1.256 2022-06-28
1.1.255 2022-06-20
1.1.254 2022-06-12
1.1.253 2022-06-08
1.1.252 2022-06-05
1.1.251 2022-06-01
1.1.250 2022-05-29
1.1.249 2022-05-25
1.1.248 2022-05-21
1.1.247 2022-05-14
1.1.246 2022-05-11
1.1.245 2022-05-07
1.1.244 2022-05-04
1.1.243 2022-05-02
1.1.242 2022-04-30
1.1.241 2022-04-27
1.1.239 2022-04-20
1.1.238 2022-04-16
1.1.237 2022-04-13
1.1.236 2022-04-10
1.1.235 2022-04-04
1.1.234 2022-03-30
1.1.233 2022-03-27
1.1.232 2022-03-23
1.1.231 2022-03-19
1.1.230 2022-03-16
1.1.229 2022-03-12
1.1.228 2022-03-09
1.1.227 2022-03-05
1.1.226 2022-03-02
1.1.225 2022-02-26
1.1.224 2022-02-25
1.1.224.post1 2022-02-26
1.1.224.post0 2022-02-25
0.0.13 2021-11-25
0.0.13.post0 2022-02-25
0.0.12 2021-11-05
0.0.11 2021-11-01
0.0.10 2021-09-26
0.0.9 2021-08-22
0.0.8 2021-08-09
0.0.7 2021-08-02
0.0.6 2021-07-30
0.0.5 2021-07-19
0.0.4 2021-07-11
0.0.3 2021-07-10
0.0.2 2021-07-02
0.0.1 2021-06-20