pants-basedpyright
basedpyright is a fast type checker for Python, forked from Pyright. Unlike Pyright, however, it does not depend on an active Node.js installation. This makes it simpler to integrate Pyright-compatible type checking into pure Python projects without depending on a separate JavaScript runtime.
basedpyright also provides several other benefits like baseline support.
This repo contains a plugin for the Pants monorepo build system to integrate basedpyright
into Pants's type checking workflow.
Supports Pants versions v2.27 - 2.29.
Features
- Runs basedpyright type checking during
$ pants checkgoal against appropriate Python targets. - No dependency on Node.js, making it easier to integrate
pyrightchecks into monorepos that don't want to manage Node.js environments and dependencies for Python tooling. - Automatic config file detection in the workspace root (
pyrightconfig.jsonas well as the[tool.basedpyright]or[tool.pyright]sections of apyproject.tomlfile). - Explicit config file path support via
[basedpyright].configsection ofpants.tomlor CLI arguments , e.g.$ pants check --basedpyright-config="path/to/config.<json|toml>" ::. - Supports installation from resolves
Installation
Add pants-basedpyright to your plugins list in pants.toml:
[GLOBAL]
plugins = [
"pants-basedpyright==0.2.0",
]
Then enable the backend in your pants.toml:
[GLOBAL]
backend_packages = [
# ...other backends...
"pants_basedpyright",
]
Configuration
Config File Discovery
By default, the plugin will look for a pyrightconfig.json or pyproject.toml file in the workspace root.
A pyproject.toml will be considered a config file candidate if it contains a [tool.basedpyright] or [tool.pyright] section,
as basedpyright supports both formats for backwards compatibility with pyright.
If both files are present, basedpyright will give precedence to pyrightconfig.json.
Explicit Config File Path
You can also specify a custom config file path in your pants.toml that will take precedence over the default discovery behavior:
[basedpyright]
config = "path/to/your/pyproject.toml" # or "path/to/your/pyrightconfig.json"
Or via the CLI (taking precedence over the pants.toml setting, if it exists):
pants check --basedpyright-config="path/to/your/pyproject.toml" :: # or "path/to/your/pyrightconfig.json"
See the Pants options docs for more details on general option setting.
Usage
Run basedpyright checks:
pants check :: # Check all targets
Advanced
Installing basedpyright from a Resolve
Pants resolves provide a mechanism to manage multiple sets of third-party dependencies.
Using resolves, you can install a different version of basedpyright than the default version specified by the plugin.
It's also possible to install basedpyright from a resolve so the tool is version-locked alongside your other Python dependencies.
See Lockfiles for tools for more details.
- To install
basedpyrightitself from a particular Pants Python resolve, first ensure resolves are enabled in yourpants.toml:
[python]
# ...other python settings...
enable_resolves = true
default_resolve = "python-default" # Optional, this is the default if not set
[python.resolves]
python-default = "3rdparty/python/python-default.lock"
custom-resolve-with-basedpyright = "path/to/your/custom-resolve.lock"
-
Run
pants generate-lockfilesto create the lockfile if you haven't already. See Lockfiles for tools for an exampleBUILDand requirements file thatgenerate-lockfileswill use to create a resolve that includespytesta tool dependency. -
Specify the resolve from which to install
basedpyrightin the[basedpyright]section of yourpants.toml:
[basedpyright]
install_from_resolve = "custom-resolve-with-basedpyright"
Now when you run pants check, the plugin will use the basedpyright version installed from the specified resolve.
License
MIT
Metadata
Release files for pants-basedpyright 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pants_basedpyright-0.3.0.tar.gz | 42.5 kB | Without provenance | Details for pants_basedpyright-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pants_basedpyright-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for pants_basedpyright-0.3.0-py3-none-any.whl |
Total release size: 57.0 kB
Release files / pants_basedpyright-0.3.0.tar.gz
| Download URL | pants_basedpyright-0.3.0.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d42cf7aeda3d7d57449cb6e1f37efd6c437ddcfaf381b49ffd0b1033cb36b82e
|
|
BLAKE2b-256 checksum How to use checksums |
ae95395eb37a0348562dc969e4429f1349718e783fa1f57d36ebbeba18b09d0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.15
|
Release files / pants_basedpyright-0.3.0-py3-none-any.whl
| Download URL | pants_basedpyright-0.3.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae6c72bd1c11f1096c857e2506a00db15bd8157c207b4f018aa449b581478232
|
|
BLAKE2b-256 checksum How to use checksums |
096cf5db878c3c5ec74824fb52dd95fd87c36388ed1c9dd8c4aa1ba1ba245c7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.15
|
Security for pants-basedpyright 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.