Skip to content

Commit f6bd828

Browse files
Technologicatclaude
andcommitted
README: tighten --root section wording
- Drop the spurious asymmetry between the two layout examples — both simply point ``--root`` at the project root; the ``NOT at the package itself`` caveat applies symmetrically and now lives in the introductory paragraph. - Note that the ``raven/__init__.py`` anchoring alternative only applies when the parent is a regular package; for a top-level namespace package, that file doesn't exist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d99b9d1 commit f6bd828

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,19 @@ Pyan derives module names from file paths relative to a *package root*. By defau
162162
1. **Top-level PEP 420 namespace package.** Layout: `proj/pyproject.toml` and `proj/ns_pkg/sub/__init__.py` with no `__init__.py` at `ns_pkg/` itself. Inference stops one level too deep and module names lose the namespace-package prefix.
163163
2. **Namespace subpackage as input.** Running e.g. `pyan3 raven/visualizer/*.py` where `visualizer/` has no `__init__.py` but `raven/` does. Inference doesn't walk up at all (the input directory itself isn't a regular package), and the result is bare basenames like `app` instead of `raven.visualizer.app`. Any relative imports fail.
164164

165-
Pyan emits a `WARNING` when it detects either situation. The fix is to pass `--root` explicitly, pointing at the *project* root (the directory above the top-level package, typically the directory containing `pyproject.toml`):
165+
Pyan emits a `WARNING` when it detects either situation. The fix is to pass `--root` explicitly, pointing at the *project* root the directory above the top-level package, typically the one containing `pyproject.toml`. Note that this is **not** the package directory itself; pointing `--root` at the package strips the package's name from the inferred module names and breaks any relative imports that cross the package boundary.
166166

167167
```bash
168168
# Layout 1: top-level namespace package
169169
pyan3 --root . ns_pkg/sub/*.py --dot
170170

171-
# Layout 2: bare-subpackage input — point at the project root, NOT at the package itself
171+
# Layout 2: bare-subpackage input
172172
pyan3 --root . raven/visualizer/*.py --dot
173+
```
174+
175+
For layout 2, an alternative is to anchor with the parent's `__init__.py` instead of using `--root` — but only when the parent is a regular (non-namespace) package, since otherwise the file doesn't exist:
173176

174-
# Equivalent for layout 2: anchor with the parent's __init__.py instead of --root
177+
```bash
175178
pyan3 raven/__init__.py raven/visualizer/*.py --dot
176179
```
177180

0 commit comments

Comments
 (0)