Skip to content

Commit 3d01f28

Browse files
committed
fix: correct parent __init__.py path for module files in _is_public_submodule
For a module file mellea/pkg/submodule.py, Griffe gives filepath ending in .py (not __init__.py). The parent __init__.py is fp.parent/__init__.py. The previous code used fp.parent.parent which is correct for packages (whose filepath IS the __init__.py) but goes one level too far for plain module files — it was checking the grandparent init instead of the parent. Effect: genslot, react, unit_test_eval and similar non-exported modules in stdlib/components were incorrectly counted as public symbols, inflating the denominator and lowering the reported coverage percentage.
1 parent 83aed3b commit 3d01f28

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tooling/docs-autogen/audit_coverage.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ def _is_public_submodule(submodule_name: str, submodule_filepath: Path | None) -
5858
return False
5959
if submodule_filepath is None:
6060
return True # conservative: keep if we can't determine
61-
# The submodule filepath is either a .py file or a package __init__.py.
62-
# The parent __init__.py to check is one level up.
63-
parent_init = submodule_filepath.parent.parent / "__init__.py"
61+
# Griffe gives filepath as:
62+
# - module file: .../pkg/submodule.py → parent init is .../pkg/__init__.py
63+
# - package: .../pkg/subpkg/__init__.py → parent init is .../pkg/__init__.py
64+
if submodule_filepath.name == "__init__.py":
65+
parent_init = submodule_filepath.parent.parent / "__init__.py"
66+
else:
67+
parent_init = submodule_filepath.parent / "__init__.py"
6468
if not parent_init.exists():
6569
return True # conservative
6670
subs = _imported_submodule_names(parent_init)

0 commit comments

Comments
 (0)