pants-ty-plugin
pants-ty-plugin adds a Pants check backend for Astral ty.
It is designed for Pants 2.31.x and currently supports Linux and macOS. The backend installs
ty as an external binary, then runs it with:
- a resolve-backed Python environment for third-party dependencies
- Pants source roots as
--extra-search-pathentries for first-party imports
That means ty can resolve imports that Pants already knows about.
Features
pants check --only=ty ...skip_ty = trueon Python targetsty.tomldiscovery[tool.ty]discovery frompyproject.toml- resolve-aware
--python - source-root-aware
--extra-search-path
Install
Option 1: install from PyPI through Pants
The recommended installation path is to use the published package from PyPI:
Add the plugin to your repo's Pants config:
[GLOBAL]
plugins = ["pants-ty==0.1.11"]
backend_packages = [
"pants.backend.python",
"pants_ty",
]
Pants installs published plugins separately from your code resolves. Do not add pants-ty
to a resolve, lockfile, or python_requirement.
Then add your ty.toml or [tool.ty] config and run:
pants help ty
pants check --only=ty ::
Option 2: vendor the plugin into a private repo
Copy only the Python package files from pants-plugins/pants_ty/ into your repo's
pants-plugins/pants_ty/ directory:
__init__.pyregister.pyrules.pyskip_field.pysubsystem.py
Do not copy this plugin repo's development-only files:
pants-plugins/BUILDpants-plugins/pants_ty/BUILDpants-plugins/lock.txttests/- this repo's
pants.toml,pyproject.toml, or GitHub workflow files
Those files are only for developing and releasing pants-ty-plugin itself. A consuming repo
should use its own resolves, lockfiles, and test setup.
Then configure:
[GLOBAL]
pants_version = "2.31.0"
backend_packages = [
"pants.backend.python",
"pants_ty",
]
pythonpath = ["%(buildroot)s/pants-plugins"]
If you accidentally copy the dev BUILD files too, you may see an error like:
UnrecognizedResolveNamesError: ... resolve ... pants-plugins
That means your consuming repo picked up this repo's internal development resolve. Remove the
copied BUILD files and keep only the plugin Python modules.
Configure
Ty's own configuration must live in either:
ty.tomlpyproject.tomlunder[tool.ty]
Do not put [tool.ty] in pants.toml. Pants options go under [ty].
Example:
[tool.ty]
exclude = [".pants.d", "dist"]
Or in a dedicated ty.toml:
exclude = [".pants.d", "dist"]
Pants exposes the plugin options under [ty]:
[ty]
args = ["--output-format=concise"]
config_discovery = true
If your ty.toml lives somewhere else in the repo, point Pants at it explicitly:
[ty]
config = "config/python/ty.toml"
Overriding the Ty binary version
You do not need a new pants-ty release for every new ty release.
From a checkout of this repo, generate a ready-to-paste config block using the repo helper script:
./scripts/generate_known_versions.py 0.0.55
The script is the source of truth for known_versions values. Do not hand-edit hashes/sizes or pull them via
other endpoints when preparing an update.
That prints:
[ty]
version = "0.0.55"
known_versions = [
"0.0.55|linux_arm64|<sha256>|<size>",
"0.0.55|linux_x86_64|<sha256>|<size>",
"0.0.55|macos_arm64|<sha256>|<size>",
"0.0.55|macos_x86_64|<sha256>|<size>",
]
Paste that block into the consuming repo's pants.toml.
Useful options:
./scripts/generate_known_versions.py 0.0.55 --platform macos_arm64 --platform linux_x86_64
./scripts/generate_known_versions.py 0.0.55 --entries-only
Release checklist shortcut:
./scripts/generate_known_versions.py <ty_version> > /tmp/ty-version.toml
cat /tmp/ty-version.toml
Each known_versions entry is version|platform|sha256|length. By default the script uses
Astral's official GitHub release archives.
You only need to do this when you want to upgrade the downloaded ty binary without changing
the plugin code. If a new ty release requires backend changes, then release a new
pants-ty version.
Run pants help-advanced ty to see the full option shape, including url_template and
url_platform_mapping.
Useful commands:
pants help ty
pants check --only=ty ::
pants check --only=ty path/to/pkg::
To skip a target:
python_sources(
name="lib",
skip_ty=True,
)
Setup
This repo expects mise and pants to already be installed:
mise: https://mise.jdx.dev/installing-mise.htmlpants: https://www.pantsbuild.org/dev/docs/getting-started/installing-pants
The mise tasks use the installed Pants launcher directly, while mise manages the repo-local
Python version used for packaging and helper scripts.
Development
This repo uses mise to install local development tools and provide
task entrypoints for linting, testing, and releases.
mise install
mise run lint
mise run test
mise run check
mise run verify
The repository-managed tools currently include:
python 3.11.14
mise run test passes PANTS_LAUNCHER=$(command -v pants) into the Pants-managed test process
so the integration tests can invoke the same installed Pants launcher inside the test sandbox.
If you prefer to run the underlying commands directly, the task mapping is:
pants lint ::
pants "--test-extra-env-vars=['PANTS_LAUNCHER=$(command -v pants)']" test ::
pants check ::
To build a distributable wheel and sdist:
python -m build
Automated releases
After you configure PyPI trusted publishing for this repository, you can cut a release with:
mise install
mise run release 0.1.11
The release task wraps scripts/release.sh and uses the repo-managed python tooling from
mise plus your installed pants launcher. The script will:
- require a clean
mainbranch - run
pants lint ::,pants test ::, andpants check :: - update the version in
pyproject.toml - update
pants-plugins/pants_ty/__init__.py - create a release commit
- create an annotated tag like
v0.1.11 - push
main - push the tag
Useful flags:
mise run release-dry-run 0.1.11
mise run release -- --skip-checks 0.1.11
Repository layout
pants-plugins/pants_ty: plugin source.mise/tasks: local development and release task wrappersmise.toml: repo-managed tool versionsscripts/generate_known_versions.py: helper to generate[ty].known_versionsoverridestests/pants_ty: unit and integration testspants.toml: local development configpants.ci.toml: CI-specific Pants settings
Notes
- The Pants plugin API is not stable across minor versions. This repo currently targets
Pants
2.31.x. - The backend only resolves imports that Pants already knows through source roots and target resolves.
Metadata
Release files for pants-ty 0.1.11
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_ty-0.1.11.tar.gz | 12.9 kB | With provenance | Details for pants_ty-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pants_ty-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for pants_ty-0.1.11-py3-none-any.whl |
Total release size: 24.6 kB
Release files / pants_ty-0.1.11.tar.gz
| Download URL | pants_ty-0.1.11.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d96e7212ffc11380bf5a0abf7e345b32f8577605d4af4a4a4cbbfef18b457b63
|
|
BLAKE2b-256 checksum How to use checksums |
f8fc0e03d7a36fd910fe74413a779f6c8374ebe887fb63dbee5ddad4d870cdee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.
Transparency logRelease files / pants_ty-0.1.11-py3-none-any.whl
| Download URL | pants_ty-0.1.11-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
298732e1da252d541afa4abda2f17c6f534baa788fdb4862bd409094fe6db0b1
|
|
BLAKE2b-256 checksum How to use checksums |
9b10ae53bd398ee363299b446d37c0f6e07ecf32349a35d586efc5f7e0e206c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.
Transparency logSecurity for pants-ty 0.1.11
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pants_ty-0.1.11.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.
Transparency logA 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.