Define __all__ across all subpackage __init__.py files#688
Merged
kaiser-dan merged 4 commits intodevfrom Mar 3, 2026
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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>
c5f9e0c to
cb83f13
Compare
Merged
kaiser-dan
reviewed
Mar 2, 2026
Collaborator
kaiser-dan
left a comment
There was a problem hiding this comment.
Thank you @leotrs , very helpful! I left a couple questions, but I think by and large this is a pretty straight-forward change.
- 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>
2 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__all__lists to all 11 subpackage__init__.pyfilesxgi/__init__.py, locking down the public API to 169 namesxgi.utilities.dual_dict→xgi.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 namesxgi/algorithms/__init__.py: 35 namesxgi/communities/__init__.py: 1 namexgi/convert/__init__.py: 27 namesxgi/drawing/__init__.py: 20 namesxgi/dynamics/__init__.py: 4 namesxgi/generators/__init__.py: 25 namesxgi/linalg/__init__.py: 11 namesxgi/readwrite/__init__.py: 17 namesxgi/utils/__init__.py: 18 namesxgi/stats/__init__.py: already had__all__(6 names)xgi/__init__.py: aggregates all subpackage__all__liststests/core/test_hypergraph.py: fix 3 references from internal path to public pathTest plan
len(xgi.__all__) == 169— all public names accounted for🤖 Generated with Claude Code