ganzua inspect
Usage: ganzua inspect [OPTIONS] [LOCKFILE]
Inspect a lockfile.
The LOCKFILE argument can be any of the following:
- file: use that path as the lockfile (e.g.
uv.lockorpoetry.lock) - directory: look for a lockfile in that directory
- gitrevision: a
<commit>:<path>identifying a lockfile in the Git history
If this argument is not specified, the one in the current working directory will be used.
Options:
-
--filter LOCKFILE-FILTERInclude/exclude packages. [default: use all] -
--format [json|markdown]Choose the output format, e.g. Markdown. [default: json] -
--no-gitDisable Git functionality. [default: enabled] -
--[no-]pypi-metadataLook up PyPI metadata for locked packages. [default: off]This will add warnings for yanked or vulnerable packages.
-
--helpShow this help message and exit.
Changed in Ganzua 0.5.0: renamed --name to --filter.
Examples
We can load various example lockfiles:
$ ganzua inspect corpus/old-uv-project
{
"packages": [
{
"name": "example",
"version": "0.1.0",
"source": {
"direct": "."
}
},
{
"name": "typing-extensions",
"version": "3.10.0.2",
"source": "pypi"
}
]
}
$ ganzua inspect corpus/new-uv-project
{
"packages": [
{
"name": "annotated-types",
"version": "0.7.0",
"source": "pypi"
},
{
"name": "example",
"version": "0.1.0",
"source": {
"direct": "."
}
},
{
"name": "typing-extensions",
"version": "4.14.1",
"source": "pypi"
}
]
}
$ ganzua inspect corpus/old-poetry-project
{
"packages": [
{
"name": "typing-extensions",
"version": "3.10.0.2",
"source": "default"
}
]
}
$ ganzua inspect corpus/new-poetry-project
{
"packages": [
{
"name": "annotated-types",
"version": "0.7.0",
"source": "default"
},
{
"name": "typing-extensions",
"version": "4.14.1",
"source": "default"
}
]
}
$ ganzua inspect corpus/new-uv-project/pylock.exported.toml
{
"packages": [
{
"name": "annotated-types",
"version": "0.7.0",
"source": "pypi"
},
{
"name": "typing-extensions",
"version": "4.14.1",
"source": "pypi"
}
]
}
Instead of producing JSON output, we can summarize lockfiles as Markdown:
$ ganzua inspect corpus/old-uv-project --format=markdown
| package | version |
|-------------------|----------|
| example | 0.1.0 |
| typing-extensions | 3.10.0.2 |
The input paths may point to directories or lockfiles. The following invocations are all equivalent:
$ ganzua inspect corpus/new-uv-project$ ganzua inspect corpus/new-uv-project/uv.lock
output for the above commands
{
"packages": [
{
"name": "annotated-types",
"version": "0.7.0",
"source": "pypi"
},
{
"name": "example",
"version": "0.1.0",
"source": {
"direct": "."
}
},
{
"name": "typing-extensions",
"version": "4.14.1",
"source": "pypi"
}
]
}
It is possible for a locked package to have no version
(see issue #4).
In this case, Ganzua will use the pseudo-version 0+undefined:
$ ganzua inspect corpus/setuptools-dynamic-version
{
"packages": [
{
"name": "setuptools-dynamic-version",
"version": "0+undefined",
"source": {
"direct": "."
}
}
]
}
Unknown file paths produce an error:
$ ganzua inspect $EXAMPLE/unknown
Usage: ganzua inspect [OPTIONS] [LOCKFILE]
Try 'ganzua inspect --help' for help.
Error: LOCKFILE: File `${EXAMPLE}/unknown` does not exist.
[command exited with status 2]
Split versions
It is possible for a project to have multiple conflicting requirements, e.g. for different Python versions, extras, or groups:
$ cat $CORPUS/split/pyproject.toml
[project]
name = "split"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"typing_extensions >=4 ; python_version >= '3.14'",
"typing_extensions >=3,<4 ; python_version < '3.14'",
]
When inspecting the lockfile, Ganzua will show all candidates:
$ ganzua inspect $CORPUS/split/uv.lock
{
"packages": [
{
"name": "split",
"version": "0.1.0",
"source": {
"direct": "."
}
},
{
"name": "typing-extensions",
"version": "3.10.0.2",
"source": "pypi"
},
{
"name": "typing-extensions",
"version": "4.15.0",
"source": "pypi"
}
]
}
$ ganzua inspect $CORPUS/split/poetry.lock
{
"packages": [
{
"name": "typing-extensions",
"version": "3.10.0.2",
"source": "default"
},
{
"name": "typing-extensions",
"version": "4.15.0",
"source": "default"
}
]
}
Split version support was added in Ganzua 0.4.0. For background on this, see the issue ganzua#5.
Filtering
Normally, inspecting a lockfile will show all results:
$ ganzua inspect $EXAMPLE --format=markdown
| package | version |
|-------------------|---------|
| annotated-types | 0.7.0 |
| example | 0.1.0 |
| typing-extensions | 4.14.1 |
However, we can use a --filter to only look at a specific package:
$ ganzua inspect $EXAMPLE --filter=annotated-types --format=markdown
| package | version |
|-----------------|---------|
| annotated-types | 0.7.0 |
Can also use glob patterns to select matching packages:
$ ganzua inspect $EXAMPLE --filter='*ex*' --format=markdown
| package | version |
|-------------------|---------|
| example | 0.1.0 |
| typing-extensions | 4.14.1 |
For further details on filters, see the filter manual.
Filtering was added in Ganzua 0.4.0.
Unstable: there's a hidden --md-links option.
$ ganzua inspect $EXAMPLE --format=markdown --md-links
| package | version |
|-----------------------------------------------------------|---------|
| [annotated-types](https://pypi.org/p/annotated-types) | 0.7.0 |
| example | 0.1.0 |
| [typing-extensions](https://pypi.org/p/typing-extensions) | 4.14.1 |
PyPI metadata
Using the --pypi-metadata flag will load package metadata from PyPI,
which can be used to audit for known-vulnerable or yanked packages,
and will also show project URLs in the JSON output.
See the PyPI metadata feature reference for examples and further details.
JSON Schema
Download: schema.inspect.json
Properties:
-
packages: array(LockedPackage)
All packages in the lockfile.In case of split versions, there can be multiple entries with the same package name.
Changed in Ganzua 0.4.0:
packagesis now a list. Previously, it was aname → LockedPackagetable.
type LockedPackage
Properties:
-
name: string
Name of the package.Added in Ganzua 0.4.0: previously, the package name was implicit.
-
version: string -
source:pypi|default|other| SourceRegistry | SourceDirect -
pypi_metadata?: PyPIMetadata
PyPI metadata for the locked package, if any.This field will only be populated if metadata was explicitly requested via
--pypi-metadata, the package seems to have been installed from PyPI, and PyPI successfully provided metadata for the new version.Added in Ganzua 0.5.0.
-
is_yanked?: bool
True if the locked package was yanked (perpypi_metadata).Added in Ganzua 0.5.0.
-
is_vulnerable?: bool
True if the locked package has a known vulnerability (perpypi_metadata).For the purposes of this flag, withdrawn vulnerabilities are ignored.
Added in Ganzua 0.5.0.
type SourceRegistry
The package is sourced from a third party registry.
Properties:
registry: string
URL or path to the registry.
type SourceDirect
The package is sourced from a specific URL or path, e.g. a Git repo or workspace path.
Properties:
direct: string
URL or path to the package (directory or archive).subdirectory?: string | null
Only allowed if the source points to an archive file.
type PyPIMetadata
Extra PyPI metadata that relates to a specific package version.
Added in Ganzua 0.5.0.
Properties:
-
yanked?: string
If this package version was yanked, the reason given.If no reason was given, a yanked package will use an empty string here.
-
vulnerabilities?: array(Vulnerability)
If this package version has vulnerabilities, details on those. -
project_urls?: mapping(string → string)
The project URLs declared in the package metadata (label → url).Well-known labels will have been replaced by their canonical name, e.g.
What's New?will be replaced bychangelog.Specifications:
type Vulnerability
Information about a known vulnerability for a specific package version.
Matches the PyPI JSON API exactly, which in turn is based on the Open Source Vulnerability format.
Properties:
id: stringsource: stringlink?: string | nullaliases?: array(string) | nulldetails?: string | nullsummary?: string | nullfixed_in?: array(string) | nullwithdrawn?: string | null