Reports the public API surface of Python modules
Project description
iceberg
The public API is the tip of the iceberg.
icebergmarks the waterline.
iceberg reports the public API surface of Python modules. It uses
Python's ast module for static analysis — no importing of user code.
Features
- Report the effective public API of any module or project; includes function signatures (parameter names, types, defaults) and class member surfaces (attributes, properties, methods)
- Uses
__all__as the authoritative public API surface when present; falls back to inferring non-underscore top-level names when absent --use-astforces AST-only inference regardless of__all__- Walks an entire Python project's module tree via AST (safe, no imports)
- Machine-readable JSON output and human-readable tree output
Installation
pip install sheridan-iceberg
Usage
# Report the public API of a project
iceberg src/
# Show as JSON (machine-readable)
iceberg src/ --format json
# Ignore __all__ entirely — always use AST inference
iceberg src/ --use-ast
Exit codes: 0 always (path existence aside); 2 if path not found.
Example output
iceberg produces an indented tree by default. Functions are shown with their
full signatures; classes are followed by an indented list of their public
members. When __init__.py declares __all__, it is the source of truth for
the whole package — only that module is shown:
$ iceberg src/mypackage/
mypackage/
__init__
Role
name: str
level: int
permissions (property) → list[str]
classmethod create(cls, name: str, level: int = ...) → Role
promote(self) → None
User
email: str
role: Role
is_active: bool
save(self) → None
helper(path: Path) → list[str]
Pass --use-ast to bypass __all__ and see every module's inferred names:
$ iceberg src/mypackage/ --use-ast
mypackage/
__init__
Role
...
User
...
helper(path: Path) → list[str]
core
Alpha
Beta
Gamma
utils
helper(path: Path) → list[str]
parse(text: str, strict: bool = ...) → dict[str, object]
JSON output
$ iceberg --format json
[
{
"module": "mypackage.utils",
"path": "src/mypackage/utils.py",
"source": "ast",
"names": ["helper", "parse"],
"detail": {
"helper": {
"kind": "function",
"signature": {
"params": [
{"name": "path", "annotation": "Path", "has_default": false, "kind": "positional_or_keyword"}
],
"return_annotation": "list[str]",
"is_async": false
}
},
"parse": {
"kind": "function",
"signature": {
"params": [
{"name": "text", "annotation": "str", "has_default": false, "kind": "positional_or_keyword"},
{"name": "strict", "annotation": "bool", "has_default": true, "kind": "positional_or_keyword"}
],
"return_annotation": "dict[str, object]",
"is_async": false
}
}
}
}
]
The source field is "__all__" when the module has an __all__ (and --use-ast is not set), "ast" otherwise.
The detail object maps each public name to its rich info. Functions have kind: "function" (or "async function") and a signature object. Classes have kind: "class", a bases list, and a members array. Plain variables (no static type info available) are absent from detail.
Programmatic usage
from sheridan.iceberg import get_public_api
# Get the public API surface — __init__.__all__ is the source of truth
api = get_public_api("src/")
# {"mypackage": ["Role", "User", "helper"]}
# Bypass __all__ and see every module's AST-inferred names
api = get_public_api("src/", use_ast=True)
# {"mypackage": [...], "mypackage.core": [...], "mypackage.utils": [...]}
How inference works
For regular modules, iceberg infers the public API from top-level definitions —
functions, classes, and assignments whose names do not start with _.
For __init__.py files, names re-exported via from x import y are also
counted, since this is the standard Python pattern for building a package's
public surface.
# foo/__init__.py
from foo.snap import Widget # Widget is inferred as public
from foo._bar import _helper # _helper is excluded (underscore)
Submodules are not automatically included. The existence of foo/snap.py
on disk does not add snap to foo.__all__ — the __init__.py is the
explicit gatekeeper. To expose a submodule, import it explicitly:
# foo/__init__.py
from foo import snap # now snap is part of the inferred public API
Test files (test_*.py, *_test.py, conftest.py) are always skipped.
Development
See CONTRIBUTING.md for details.
Project details
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 sheridan_iceberg-3.0.0.tar.gz.
File metadata
- Download URL: sheridan_iceberg-3.0.0.tar.gz
- Upload date:
- Size: 63.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d95702df3f197bd1ea248a77f573aec041bd7053f49e14f3b6528eb00a22d8d1
|
|
| MD5 |
4ec50f35fad92e3c77db4498c8d1d182
|
|
| BLAKE2b-256 |
d1e48878070bb95493a156d087fa7087751656a9cc54dc09bfa2e652811f8fab
|
Provenance
The following attestation bundles were made for sheridan_iceberg-3.0.0.tar.gz:
Publisher:
publish.yaml on andrewasheridan/iceberg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sheridan_iceberg-3.0.0.tar.gz -
Subject digest:
d95702df3f197bd1ea248a77f573aec041bd7053f49e14f3b6528eb00a22d8d1 - Sigstore transparency entry: 1193424168
- Sigstore integration time:
-
Permalink:
andrewasheridan/iceberg@5a71ac340264156eadfd7d7a0ba63a4286bc9cb2 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/andrewasheridan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5a71ac340264156eadfd7d7a0ba63a4286bc9cb2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sheridan_iceberg-3.0.0-py3-none-any.whl.
File metadata
- Download URL: sheridan_iceberg-3.0.0-py3-none-any.whl
- Upload date:
- Size: 17.4 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 |
cce9bbf695b4bb93b2d3bc553521e289ac041dc10e9f38ac75bd3d2e8e1f27e4
|
|
| MD5 |
e2551b9c53b172ea22191138cf0cd7c2
|
|
| BLAKE2b-256 |
4d0f6d3e68c0d3ef382a1d534868776fec6898d9ad8e78a285745c7148494e04
|
Provenance
The following attestation bundles were made for sheridan_iceberg-3.0.0-py3-none-any.whl:
Publisher:
publish.yaml on andrewasheridan/iceberg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sheridan_iceberg-3.0.0-py3-none-any.whl -
Subject digest:
cce9bbf695b4bb93b2d3bc553521e289ac041dc10e9f38ac75bd3d2e8e1f27e4 - Sigstore transparency entry: 1193424203
- Sigstore integration time:
-
Permalink:
andrewasheridan/iceberg@5a71ac340264156eadfd7d7a0ba63a4286bc9cb2 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/andrewasheridan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5a71ac340264156eadfd7d7a0ba63a4286bc9cb2 -
Trigger Event:
push
-
Statement type: