Skip to main content

iceberg

CI PyPI License: MIT Python 3.14+

The public API is the tip of the iceberg. iceberg marks the waterline.

iceberg inspects and snapshots the public API surface of a Python package. It reads source with Python's ast module and never imports or executes your code, and it has no runtime dependencies.

Features

  • Reports every public module, class, function, and assignment, with full signatures (parameter names, annotations, defaults) and class members.
  • Uses __all__ as the source of truth when present and falls back to underscore-prefix inference when it is absent.
  • Resolves re-exports through __init__.py, including relative imports, absolute imports, namespace packages, and imports inside try / if blocks.
  • Never drops a public name silently: anything it cannot resolve to a definition (e.g. from math import sqrt listed in __all__) is reported as a reference.
  • Human-readable tree output and deterministic JSON output.

Installation

pip install sheridan-iceberg

CLI

iceberg src/mypkg            # tree output
iceberg src/mypkg --json     # machine-readable output
python -m sheridan.iceberg src/mypkg

The path may be a package directory, a directory containing packages (such as src/ or a namespace package), or a single .py file. iceberg names packages after the path it is given: iceberg src/sheridan reports sheridan.iceberg, while iceberg src/sheridan/iceberg reports iceberg.

Exit codes: 0 on success, 1 for iceberg errors (missing path, invalid config, unparseable source), 2 for unexpected errors.

Example output

$ iceberg cases/case_11
package case_11
├── def area(radius: float) -> float
├── from collections import OrderedDict as Ordered
├── import json
├── lazy_thing (unresolved)
└── from math import sqrt

Definitions come first. Public names that iceberg could not resolve to a definition follow, shown as the import that binds them. A name with no binding import at all (here, one served by a module-level __getattr__) is marked (unresolved).

When a package's __init__.py defines __all__, its exports are hoisted to the package level and private submodules are hidden. Without __all__, every public module is listed:

$ iceberg cases/case_09
package case_09
├── module case_09.alpha
│   ├── def add(x: int, y: int) -> int
│   └── def subtract(x: int, y: int) -> int
├── module case_09.beta
│   └── class Counter
│       ├── def __init__(self, start: int = 0) -> None
│       ├── def increment(self) -> None
│       └── def value(self) -> int
└── module case_09.gamma
    ├── VERSION: str
    └── MAX_RETRIES: int

The cases/ directory documents each supported layout and edge case alongside its expected output.

Programmatic use

from pathlib import Path

from sheridan.iceberg import get_public_api

api = get_public_api(Path("src/mypkg"))
for function in api.functions:
    print(function.name)

get_public_api returns a Package (or a Module when given a single file). A Package is a trie of modules and subpackages; its assignments, classes, functions, and references properties expose the package-level (__init__.py) surface. All models are frozen dataclasses: Package, Module, Class, Function, Parameter, Assignment, and Reference.

sheridan.iceberg.utilities provides helpers for building the same models from smaller inputs: get_function, get_class, get_assignment, get_module, and get_package accept source strings, AST nodes, paths, or live objects.

Configuration

iceberg walks up from the analyzed path looking for .iceberg.toml or a [tool.iceberg] table in pyproject.toml. Unknown keys are rejected.

[tool.iceberg]
# Regex matched against each file's POSIX path; matches are skipped.
test_module_pattern = '(^|/)tests?(/|$)|(^|/)test_[^/]*\.py$|_test\.py$'
# Worker processes used to parse modules (default: 1, in-process). Only very
# large trees benefit; values above 1 require scripts calling get_public_api
# to be guarded by `if __name__ == "__main__":`.
max_workers = 1

To bypass file discovery, pass a Config directly:

import re
from pathlib import Path

from sheridan.iceberg import Config, get_public_api

api = get_public_api(Path("src/mypkg"), config=Config(test_module_pattern=re.compile(r"_test\.py$")))

Development

task install   # set up the environment
task ci        # lint, format check, type check, tests

See CONTRIBUTING.md for details.

Metadata

Release files for sheridan-iceberg 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sheridan-iceberg 4.0.0
File Size Uploaded Provenance Actions
sheridan_iceberg-4.0.0.tar.gz 78.8 kB With provenance Details for sheridan_iceberg-4.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sheridan-iceberg 4.0.0
File Interpreter ABI Platform Actions
sheridan_iceberg-4.0.0-py3-none-any.whl Python 3 none any Details for sheridan_iceberg-4.0.0-py3-none-any.whl

Total release size: 114.7 kB

Release files / sheridan_iceberg-4.0.0.tar.gz

Download URL sheridan_iceberg-4.0.0.tar.gz
Size 78.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8e673caef3b385ec22b9ae0e9a929e3a135deb7512dd32aa2d1c6db3f7336941
BLAKE2b-256 checksum
How to use checksums
87b254b46f8f683b4fcc136bab09d71135255b3ca735e4905828b47d27ea0b0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / sheridan_iceberg-4.0.0-py3-none-any.whl

Download URL sheridan_iceberg-4.0.0-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fec5bc3390273cec0d40f6148ca48aa6db316d1354f243d76c0ded537d618f4e
BLAKE2b-256 checksum
How to use checksums
2f5b27ae38232f3aa884b7a280c596f2f4aee6aa5e7a4aaa02031cdf462d1aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for sheridan-iceberg 4.0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sheridan_iceberg-4.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page