Skip to content

Define __all__ across all subpackage __init__.py files#688

Merged
kaiser-dan merged 4 commits intodevfrom
define-all-exports
Mar 3, 2026
Merged

Define __all__ across all subpackage __init__.py files#688
kaiser-dan merged 4 commits intodevfrom
define-all-exports

Conversation

@leotrs
Copy link
Collaborator

@leotrs leotrs commented Feb 27, 2026

Summary

  • Add explicit __all__ lists to all 11 subpackage __init__.py files
  • Aggregate them in the top-level xgi/__init__.py, locking down the public API to 169 names
  • Fix tests that relied on leaked internal module paths (xgi.utilities.dual_dictxgi.dual_dict)

Context

Without __all__, wildcard imports (from xgi import *) would export everything including internal submodules. This makes the public API boundary unclear and fragile. For v1.0, we need an explicit contract of what's public.

Changes

  • xgi/core/__init__.py: 4 names
  • xgi/algorithms/__init__.py: 35 names
  • xgi/communities/__init__.py: 1 name
  • xgi/convert/__init__.py: 27 names
  • xgi/drawing/__init__.py: 20 names
  • xgi/dynamics/__init__.py: 4 names
  • xgi/generators/__init__.py: 25 names
  • xgi/linalg/__init__.py: 11 names
  • xgi/readwrite/__init__.py: 17 names
  • xgi/utils/__init__.py: 18 names
  • xgi/stats/__init__.py: already had __all__ (6 names)
  • xgi/__init__.py: aggregates all subpackage __all__ lists
  • tests/core/test_hypergraph.py: fix 3 references from internal path to public path

Test plan

  • All 393 tests pass
  • len(xgi.__all__) == 169 — all public names accounted for
  • Internal modules no longer leak through wildcard imports

🤖 Generated with Claude Code

Add explicit __all__ lists to every subpackage (core, algorithms,
communities, convert, drawing, dynamics, generators, linalg, readwrite,
utils) and aggregate them in the top-level xgi/__init__.py. This locks
down the public API surface to 169 names, preventing internal modules
from leaking through wildcard imports.

Also fixes tests that accessed xgi.utilities.dual_dict (an internal
module path that was only reachable via leaked wildcard imports) to use
the correct public path xgi.dual_dict.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.61%. Comparing base (cc32ef6) to head (cb83f13).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #688      +/-   ##
==========================================
+ Coverage   93.59%   93.61%   +0.01%     
==========================================
  Files          66       66              
  Lines        5123     5134      +11     
==========================================
+ Hits         4795     4806      +11     
  Misses        328      328              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Pandas now uses dtype='str' instead of dtype='object' for string Index
columns. Update the expected doctest output in IDStat.name accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@leotrs leotrs force-pushed the define-all-exports branch from c5f9e0c to cb83f13 Compare February 27, 2026 15:04
@kaiser-dan kaiser-dan changed the base branch from main to dev March 1, 2026 22:58
@kaiser-dan kaiser-dan mentioned this pull request Mar 2, 2026
Copy link
Collaborator

@kaiser-dan kaiser-dan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @leotrs , very helpful! I left a couple questions, but I think by and large this is a pretty straight-forward change.

kaiser-dan and others added 2 commits March 2, 2026 12:45
- Remove read_json/write_json from readwrite __all__ (deprecated)
- Remove IDDict, Trie, crest_r from utils __all__ (internal)
- Update test imports to use direct module paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kaiser-dan kaiser-dan merged commit ede0d53 into dev Mar 3, 2026
2 checks passed
@kaiser-dan kaiser-dan deleted the define-all-exports branch March 3, 2026 14:54
leotrs added a commit that referenced this pull request Mar 9, 2026
Per the decision in #688, these deprecated functions should not be in
the public API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants