pep723-loader
A CLI wrapper that auto-installs PEP 723 inline script dependencies before executing linters and other tools.
The Problem
Python scripts with PEP 723 inline metadata declare their dependencies directly in the file:
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "requests>=2.31.0",
# "rich>=13.0.0",
# ]
# ///
import requests
from rich import print
# ...
But when you run type checkers or linters on these scripts, they fail because the dependencies aren't installed:
$ mypy script.py
script.py:8: error: Cannot find implementation or library stub for module named "requests"
script.py:9: error: Cannot find implementation or library stub for module named "rich"
The Solution
pep723-loader wraps your linter and automatically installs the inline dependencies first:
$ pep723-loader mypy script.py
# Dependencies installed, then mypy runs successfully
Installation
pip install pep723-loader
Or with uv:
uv tool install pep723-loader
Usage
Command Line
# Wrap any linter or tool
pep723-loader mypy script.py
pep723-loader basedpyright script.py
pep723-loader ruff check script.py
pep723-loader bandit script.py
# Pass any arguments through to the wrapped command
pep723-loader mypy --strict --warn-unreachable script.py
# Works with directories too
pep723-loader mypy scripts/
Pre-commit Integration
There are two ways to use pep723-loader with pre-commit:
Simple: If tools are already installed
First, add the tools to your project's dev dependencies:
uv add --dev pep723-loader mypy
Then configure the hook:
- repo: local
hooks:
- id: mypy
name: mypy
entry: pep723-loader mypy
language: system
types: [python]
pass_filenames: true
Recommended: Self-contained with uv
This approach keeps tools out of your project's dependencies - uv provides them on-demand:
- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run -q --no-sync --with pep723-loader --with mypy pep723-loader mypy
language: system
types: [python]
pass_filenames: true
- id: basedpyright
name: basedpyright
entry: uv run -q --no-sync --with pep723-loader --with basedpyright pep723-loader basedpyright
language: system
types: [python]
pass_filenames: true
What do these flags do?
| Flag | Purpose |
|---|---|
-q |
Quiet mode - suppresses uv's output so only linter output is shown |
--no-sync |
Skip syncing the project's dependencies - faster, we only need the tools |
--with <pkg> |
Temporarily add a package for this invocation |
The --with packages are ephemeral - they're not installed into your project's virtualenv. However, they're cached by uv, so after the first run there's no download overhead.
How It Works
- Scans Python files passed as arguments for PEP 723
# /// scriptmetadata blocks - Extracts dependencies using
uv export --script - Installs dependencies via
uv pip install - Executes the wrapped command with all original arguments
- Propagates the wrapped command's exit code
Requirements
- Python 3.10+
- uv (used for dependency extraction and installation)
Related Projects
- pep723-uv-interpreter - VS Code extension that automatically sets the Python interpreter for PEP 723 scripts, enabling auto-completion and intellisense in your editor.
These tools are complementary: pep723-uv-interpreter solves the IDE experience, while pep723-loader solves CI/pre-commit linting.
License
Apache License 2.0
Metadata
Release files for pep723-loader 0.12.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 |
|---|---|---|---|---|
| pep723_loader-0.12.0.tar.gz | 25.6 kB | Without provenance | Details for pep723_loader-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pep723_loader-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for pep723_loader-0.12.0-py3-none-any.whl |
Total release size: 53.1 kB
Release files / pep723_loader-0.12.0.tar.gz
| Download URL | pep723_loader-0.12.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f31f63df00df7ea4f6b7258c24c531ad31715d92253ee9297b03b701c52407f1
|
|
BLAKE2b-256 checksum How to use checksums |
122ed8cb964c3fde5ee994b11d795ed02e67807f1a094797f859ce33ac53d9d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pep723_loader-0.12.0-py3-none-any.whl
| Download URL | pep723_loader-0.12.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2c5b2f1ce991615244f42d0855828dca917f4fee3a3a35e06bd61b713ab321f
|
|
BLAKE2b-256 checksum How to use checksums |
7288583a36e89a8e298afa09096f199608f2a383de2b1d41c3eb02576472f733
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pep723-loader 0.12.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.