Skip to main content

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.412
    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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyright-1.1.412.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyright-1.1.412-py3-none-any.whl (6.2 MB view details)

Uploaded Python 3

File details

Details for the file pyright-1.1.412.tar.gz.

File metadata

  • Download URL: pyright-1.1.412.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.16

File hashes

Hashes for pyright-1.1.412.tar.gz
Algorithm Hash digest
SHA256 9905e44666ee23f25f1741df44811063bebbb7f700da1845a21cb7f944a8ce53
MD5 ceadb6e86d608e8e1f6412fc016fff5c
BLAKE2b-256 1d86d52ff958a567992004f8ba8ef7e02eba6cd4d50f8385dcfe8222752f66a5

See more details on using hashes here.

File details

Details for the file pyright-1.1.412-py3-none-any.whl.

File metadata

  • Download URL: pyright-1.1.412-py3-none-any.whl
  • Upload date:
  • Size: 6.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.16

File hashes

Hashes for pyright-1.1.412-py3-none-any.whl
Algorithm Hash digest
SHA256 8c8da2e8e8ecb21c59b5ccd17a19dda9af00a9f5492cc767b2e42638ce803b08
MD5 cc831f1aac64871b9b9476f02e010540
BLAKE2b-256 6be5201e83185424bceebbb736e12bea356f9045325b9c063a43d49b1a097c74

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.413

2 files

This release

1.1.412 This release

2 files

1.1.411

2 files

1.1.410

2 files

1.1.409

2 files

1.1.408

2 files

1.1.407

2 files

1.1.406

2 files

1.1.405

2 files

1.1.404

2 files

1.1.403

2 files

1.1.402

2 files

1.1.401

2 files

1.1.400

2 files

1.1.399

2 files

1.1.398

2 files

1.1.397

2 files

1.1.396

2 files

1.1.395

2 files

1.1.394

2 files

1.1.393

2 files

1.1.392.post0

2 files

1.1.392

2 files

1.1.391

2 files

1.1.390

2 files

1.1.389

2 files

1.1.388

2 files

1.1.387

2 files

1.1.386

2 files

1.1.385

2 files

1.1.384

2 files

1.1.383

2 files

1.1.382.post1

2 files

1.1.382.post0

2 files

1.1.382

2 files

1.1.381

2 files

1.1.380

2 files

1.1.379

2 files

1.1.378

2 files

1.1.377

2 files

1.1.376

2 files

1.1.375

2 files

1.1.374

2 files

1.1.373

2 files

1.1.372

2 files

1.1.371

2 files

1.1.370

2 files

1.1.369

2 files

1.1.368

2 files

1.1.367

2 files

1.1.366

2 files

1.1.365

2 files

1.1.364

2 files

1.1.363

2 files

1.1.362

2 files

1.1.361

2 files

1.1.360

2 files

1.1.359

2 files

1.1.358

2 files

1.1.357

2 files

1.1.356

2 files

1.1.355

2 files

1.1.354

2 files

1.1.353

2 files

1.1.352

2 files

1.1.351

2 files

1.1.350

2 files

1.1.349

2 files

1.1.348

2 files

1.1.347

2 files

1.1.346

2 files

1.1.345

2 files

1.1.344

2 files

1.1.343

2 files

1.1.342

2 files

1.1.341

2 files

1.1.340

2 files

1.1.339

2 files

1.1.338

2 files

1.1.337

2 files

1.1.336

2 files

1.1.335

2 files

1.1.334

2 files

1.1.333

2 files

1.1.332

2 files

1.1.331

2 files

1.1.330.post0

2 files

1.1.330

2 files

1.1.329

2 files

1.1.328

2 files

1.1.327

2 files

1.1.326

2 files

1.1.325

2 files

1.1.324

2 files

1.1.323

2 files

1.1.322

2 files

1.1.321

2 files

1.1.320

2 files

1.1.318

2 files

1.1.317

2 files

1.1.316

2 files

1.1.315

2 files

1.1.314

2 files

1.1.313

2 files

1.1.312

2 files

1.1.311

2 files

1.1.310

2 files

1.1.309

2 files

1.1.308

2 files

1.1.307

2 files

1.1.306

2 files

1.1.305

2 files

1.1.304

2 files

1.1.303

2 files

1.1.302

2 files

1.1.301

2 files

1.1.300

2 files

1.1.299

2 files

1.1.298

2 files

1.1.297

2 files

1.1.296

2 files

1.1.295

2 files

1.1.294

2 files

1.1.293

2 files

1.1.292

2 files

1.1.291

2 files

1.1.290

2 files

1.1.289

2 files

1.1.288

2 files

1.1.287

2 files

1.1.286

2 files

1.1.285

2 files

1.1.284

2 files

1.1.283

2 files

1.1.282

2 files

1.1.281

2 files

1.1.280

2 files

1.1.279

2 files

1.1.278

2 files

1.1.277

2 files

1.1.276

2 files

1.1.275

2 files

1.1.274

2 files

1.1.273

2 files

1.1.272

2 files

1.1.271

2 files

1.1.270

2 files

1.1.269

2 files

1.1.268

2 files

1.1.267

2 files

1.1.266

2 files

1.1.265

2 files

1.1.264

2 files

1.1.263

2 files

1.1.262

2 files

1.1.261

2 files

1.1.260

2 files

1.1.259

2 files

1.1.258

2 files

1.1.257

2 files

1.1.256

2 files

1.1.255

2 files

1.1.254

2 files

1.1.253

2 files

1.1.252

2 files

1.1.251

2 files

1.1.250

2 files

1.1.249

2 files

1.1.248

2 files

1.1.247

2 files

1.1.246

2 files

1.1.245

2 files

1.1.244

2 files

1.1.243

2 files

1.1.242

2 files

1.1.241

2 files

1.1.239

2 files

1.1.238

2 files

1.1.237

2 files

1.1.236

2 files

1.1.235

2 files

1.1.234

2 files

1.1.233

2 files

1.1.232

2 files

1.1.231

2 files

1.1.230

2 files

1.1.229

2 files

1.1.228

2 files

1.1.227

2 files

1.1.226

2 files

1.1.225

2 files

1.1.224.post1

2 files

1.1.224.post0

2 files

1.1.224

2 files

0.0.13.post0

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page