Skip to main content

A Pants check backend for the Astral ty Python type checker.

Reason this release was yanked:

doesn't install properly

Project description

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-path entries for first-party imports

That means ty can resolve imports that Pants already knows about.

Features

  • pants check --only=ty ...
  • skip_ty = true on Python targets
  • ty.toml discovery
  • [tool.ty] discovery from pyproject.toml
  • resolve-aware --python
  • source-root-aware --extra-search-path

Install

Option 1: 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__.py
  • register.py
  • rules.py
  • skip_field.py
  • subsystem.py

Do not copy this plugin repo's development-only files:

  • pants-plugins/BUILD
  • pants-plugins/pants_ty/BUILD
  • pants-plugins/lock.txt
  • tests/
  • 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.

Option 2: install as a published plugin

Once the package is published, use:

[GLOBAL]
plugins = ["pants-ty==0.1.0"]
backend_packages = [
  "pants.backend.python",
  "pants_ty",
]

Configure

Create either ty.toml or add [tool.ty] to pyproject.toml.

Example:

[tool.ty]
exclude = [".pants.d", "dist"]

Pants exposes the plugin options under [ty]:

[ty]
args = ["--output-format=concise"]
config_discovery = true

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,
)

Development

This repo uses Pants to lint, test, and dogfood the plugin itself.

ruff check pants-plugins tests
pants test ::
pants check ::

To build a distributable wheel and sdist:

python -m build

Repository layout

  • pants-plugins/pants_ty: plugin source
  • tests/pants_ty: unit and integration tests
  • pants.toml: local development config
  • pants.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.

Project details


Download files

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

Source Distribution

pants_ty-0.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

pants_ty-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pants_ty-0.1.0.tar.gz.

File metadata

  • Download URL: pants_ty-0.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pants_ty-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99cc802db1a02ab1790c7133848fa80ba0229c719fdf511d6e76fdfc24427ba8
MD5 12e6dc07bd9530d0c463d29fa7d06bd8
BLAKE2b-256 656d8fd6036d769d8ee1f4be079929cd7f68d3ef6e414caec1f7863b09bbff09

See more details on using hashes here.

Provenance

The following attestation bundles were made for pants_ty-0.1.0.tar.gz:

Publisher: release.yml on vrazdalovschi/pants-ty-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pants_ty-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pants_ty-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pants_ty-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20330c55ff3c62a090507eb554e0e6fcf801c2d1c97834709040c2d4da9376b1
MD5 306f387413e49fd76dcb56769f142e6b
BLAKE2b-256 90c226e8822d45c6b191f762581e70f8e14493d80056be92bfd5248f4f5d016b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pants_ty-0.1.0-py3-none-any.whl:

Publisher: release.yml on vrazdalovschi/pants-ty-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page