Modules¶
An overview of the packages that make up peta.
The API reference below is generated automatically from the source docstrings.
Core (peta.core)¶
Core data models for peta.
- class peta.core.models.DependencyNode(name, version_spec, installed_version=None, children=<factory>, circular=False)[source]¶
Bases:
objectA node in a package’s recursive dependency tree.
- class peta.core.models.PackageInfo(name, version, source, summary=None, author=None, author_email=None, maintainer=None, license=None, python_requires=None, homepage=None, project_urls=<factory>, dependencies=<factory>, classifiers=<factory>, keywords=<factory>, files=None, vulnerabilities=<factory>, download_count=None, dependent_count=None)[source]¶
Bases:
objectPackage metadata from a local installation or PyPI.
- Parameters:
- class peta.core.models.Vulnerability(id, aliases, summary, fixed_in, severity=None)[source]¶
Bases:
objectA known security vulnerability for a package.
Local package metadata fetcher using importlib.metadata.
- exception peta.core.local.PackageNotFoundError(name)[source]¶
Bases:
ExceptionRaised when a package is not installed locally.
Store the missing package name.
- Parameters:
name (str)
- Return type:
None
- peta.core.local.get_package(name)[source]¶
Get metadata for a locally installed package.
- Parameters:
- Returns:
A
PackageInfowithsource="local".- Raises:
PackageNotFoundError – If the package is not installed.
- Return type:
PyPI JSON API client for remote package metadata.
- exception peta.core.remote.NetworkError(message)[source]¶
Bases:
ExceptionRaised when a network request fails.
Wrap a network failure message.
- Parameters:
message (str)
- Return type:
None
- exception peta.core.remote.PackageNotFoundError(name, version=None)[source]¶
Bases:
ExceptionRaised when a package is not found on PyPI.
Store the missing package name and optional version.
- class peta.core.remote.PyPIInfo[source]¶
Bases:
TypedDictThe
infoobject of a PyPI package payload.
- class peta.core.remote.PyPIReleaseFile[source]¶
Bases:
TypedDictA single distribution file within a release entry.
- class peta.core.remote.PyPIResponse[source]¶
Bases:
TypedDictThe top-level PyPI JSON payload for a package.
- class peta.core.remote.PyPIVulnerability[source]¶
Bases:
TypedDictA single entry of the
vulnerabilitiesarray.
CLI (peta.cli)¶
Typer application and command registration.
- peta.cli.app.compare(ctx, a, b, use_json=False, local=False, remote=False, no_osv=False, no_stats=False)[source]¶
Compare two packages’ metadata side by side.
- Parameters:
ctx (Context)
a (Annotated[str, <typer.models.ArgumentInfo object at 0x7f01f92c74d0>])
b (Annotated[str, <typer.models.ArgumentInfo object at 0x7f01f92c7610>])
use_json (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f92c7750>])
local (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f92c7890>])
remote (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f92c79d0>])
no_osv (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f92c7b10>])
no_stats (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f92c7c50>])
- Return type:
None
- peta.cli.app.deps(ctx, package, use_json=False, local=False, remote=False, why=None, depth=10)[source]¶
Show a package’s recursive dependency tree.
- Parameters:
ctx (Context)
package (Annotated[str, <typer.models.ArgumentInfo object at 0x7f01f9184550>])
use_json (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9184690>])
local (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f91847d0>])
remote (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9184910>])
why (Annotated[str | None, <typer.models.OptionInfo object at 0x7f01f9184a50>])
depth (Annotated[int, <typer.models.OptionInfo object at 0x7f01f9184b90>])
- Return type:
None
- peta.cli.app.info(ctx, package, use_json=False, local=False, remote=False, no_osv=False, no_stats=False)[source]¶
Show detailed package metadata.
- Parameters:
ctx (Context)
package (Annotated[str, <typer.models.ArgumentInfo object at 0x7f01f9185950>])
use_json (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9185a90>])
local (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9185bd0>])
remote (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9185d10>])
no_osv (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9185e50>])
no_stats (Annotated[bool, <typer.models.OptionInfo object at 0x7f01f9185f90>])
- Return type:
None
- peta.cli.app.main(ctx, _version=False, no_color=False)[source]¶
Human-friendly Python package metadata viewer.
- peta.cli.app.run()[source]¶
Entry point;
peta <package>is shorthand forpeta info <package>.- Return type:
None
- peta.cli.app.versions(ctx, package, use_json=False, limit=20)[source]¶
Show published versions of a package from PyPI.
Rich text output formatters.
- peta.cli.output.tables.render_compare(a, b, *, color)[source]¶
Render two
PackageInfoobjects as a side-by-side Rich table.- Returns:
The comparison table rendered as text.
- Parameters:
a (PackageInfo)
b (PackageInfo)
color (bool)
- Return type:
- peta.cli.output.tables.render_dep_tree(node, *, color)[source]¶
Render a recursive dependency tree as a Rich tree string.
- Returns:
The dependency tree rendered as text.
- Parameters:
node (DependencyNode)
color (bool)
- Return type:
- peta.cli.output.tables.render_files(pkg, *, color)[source]¶
Render a package’s file listing as a string.
coloris accepted for signature parity with the other renderers but unused: this output is plain lines, not a Rich renderable.- Returns:
The file listing rendered as text.
- Parameters:
pkg (PackageInfo)
color (bool)
- Return type:
- peta.cli.output.tables.render_info(pkg, *, color)[source]¶
Render
PackageInfoas a Rich panel string.- Returns:
The formatted panel text, with any vulnerability block appended.
- Parameters:
pkg (PackageInfo)
color (bool)
- Return type:
- peta.cli.output.tables.render_versions(name, versions, *, color)[source]¶
Render a version list as a Rich table string.
- peta.cli.output.tables.render_why(target, paths, *, color)[source]¶
Render root-to-target dependency chains as arrow-joined lines.
coloris accepted for signature parity with the other renderers but unused: this output is plain lines, not a Rich renderable.
JSON output formatters.
- peta.cli.output.json.format_compare(a, b)[source]¶
Format two
PackageInfoobjects as a JSON comparison string.- Returns:
A
{"packages": [a, b]}JSON string, each package in the same format asformat_info().- Parameters:
a (PackageInfo)
b (PackageInfo)
- Return type:
- peta.cli.output.json.format_dep_tree(node)[source]¶
Format a recursive dependency tree as a JSON string.
- Returns:
The dependency tree serialized as an indented JSON string.
- Parameters:
node (DependencyNode)
- Return type:
- peta.cli.output.json.format_files(pkg)[source]¶
Format a package’s file list as a JSON string.
- Returns:
The file list serialized as an indented JSON string.
- Parameters:
pkg (PackageInfo)
- Return type:
- peta.cli.output.json.format_info(pkg)[source]¶
Format
PackageInfoas a JSON string.- Returns:
The metadata serialized as an indented JSON string.
- Parameters:
pkg (PackageInfo)
- Return type:
- peta.cli.output.json.format_versions(name, versions)[source]¶
Format a version list as a JSON string.
- peta.cli.output.json.format_why(target, paths)[source]¶
Format root-to-target dependency chains as a JSON string.
The peta info command.
- peta.cli.commands.info.info(package, *, use_json=False, local=False, remote=False, color=False, no_osv=False, no_stats=False)[source]¶
Show detailed package metadata.
The peta deps command.
- peta.cli.commands.deps.deps(package, *, use_json=False, local=False, remote=False, color=False, why=None, depth=10)[source]¶
Show a package’s recursive dependency tree, or
--whya target is pulled in.
The peta files command.
- peta.cli.commands.files.files(package, *, use_json=False, color=False)[source]¶
List files installed by a local package.
The peta versions command.
- peta.cli.commands.versions.get_versions(name)[source]¶
Fetch all published versions for a package from PyPI.
- Returns:
A list of
{"version", "upload_time"}dicts, newest first; empty if the package is not found (HTTP 404).- Raises:
NetworkError – If the request fails, returns a non-success status, or the decoded body is malformed (not a dict, or
releasesis not a dict).- Parameters:
name (str)
- Return type: