Pytest plugin to verify PEP 723 inline script metadata covers all imports.
Project description
pytest-pep723
A pytest plugin that verifies PEP 723 inline script metadata covers all imports.
When you use uv run to dispatch scripts with inline metadata blocks like:
# /// script
# dependencies = [
# "click",
# "numpy",
# ]
# ///
...only the declared dependencies are available at runtime. If you add an
import readcon but forget to add readcon to the deps block, the script
fails at dispatch time. This plugin catches those gaps statically.
Installation
uv add --group dev pytest-pep723
Usage
# Scan all .py files under src/ for PEP 723 scripts
pytest --pep723-check --pep723-paths src/
# Ignore internal/conda-only packages
pytest --pep723-check --pep723-paths src/ --pep723-ignore mypkg --pep723-ignore ira_mod
Or configure in pyproject.toml:
[tool.pytest.ini_options]
pep723_paths =
src/mypkg
pep723_ignore_imports =
mypkg
ira_mod
pep723_extra_mappings =
gi=pygobject
myspecial=my-special-pkg
Then just:
pytest --pep723-check
What it checks
For every .py file under the configured paths that contains a
# /// script block:
- Parses the declared dependencies from inline metadata
- Extracts all
importandfrom X importstatements via AST - Skips stdlib and ignored imports
- Maps import names to PyPI package names (handles
PIL->pillow, etc.) - Reports any import not covered by the declared deps
Features
- Handles multi-line and single-line dependency formats
- Supports all version operators (
>=,~=,[extras], etc.) - Built-in mapping for 20+ packages where import name differs from pip name
- Configurable ignore list for internal packages and conda-only deps
- Custom import-to-package mappings via
pep723_extra_mappings - Registers a
pep723marker for selective test runs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_pep723-0.1.0.tar.gz.
File metadata
- Download URL: pytest_pep723-0.1.0.tar.gz
- Upload date:
- Size: 72.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
563d8268b942002c576ae24f75ce708725d42e5b1dad191c353f5ae120d0fae1
|
|
| MD5 |
1eba0c6e5e5aad4ca16ce095adcc7774
|
|
| BLAKE2b-256 |
41dcacdca797b621dd84112666308b304777a0afeb9a72c3da5b4d73ff3021f9
|
Provenance
The following attestation bundles were made for pytest_pep723-0.1.0.tar.gz:
Publisher:
release.yml on HaoZeke/pytest-pep723
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_pep723-0.1.0.tar.gz -
Subject digest:
563d8268b942002c576ae24f75ce708725d42e5b1dad191c353f5ae120d0fae1 - Sigstore transparency entry: 1244599764
- Sigstore integration time:
-
Permalink:
HaoZeke/pytest-pep723@d5796553425ca2afb5a0669b9fe2c863d506fcc4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HaoZeke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d5796553425ca2afb5a0669b9fe2c863d506fcc4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_pep723-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_pep723-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63b91ddc3704d544a359d7a46131c4c3e8447e8a3ec912715694813b1c2a7c5f
|
|
| MD5 |
7e4cb1b64309ebcd739c0547345485d6
|
|
| BLAKE2b-256 |
8bbb337b91e3657295753fd0a40f3446ff59d5a68a3131e6336122ae235c3979
|
Provenance
The following attestation bundles were made for pytest_pep723-0.1.0-py3-none-any.whl:
Publisher:
release.yml on HaoZeke/pytest-pep723
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_pep723-0.1.0-py3-none-any.whl -
Subject digest:
63b91ddc3704d544a359d7a46131c4c3e8447e8a3ec912715694813b1c2a7c5f - Sigstore transparency entry: 1244599818
- Sigstore integration time:
-
Permalink:
HaoZeke/pytest-pep723@d5796553425ca2afb5a0669b9fe2c863d506fcc4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HaoZeke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d5796553425ca2afb5a0669b9fe2c863d506fcc4 -
Trigger Event:
push
-
Statement type: