Skip to content

Conversation

@adrn
Copy link
Collaborator

@adrn adrn commented Aug 11, 2025

This first sorts the list of potential names alphabetically in the builtin __init__.py. I then also was puzzling at why we need another manual list of potential names in galax/potential/__init__.py for the public API -- it's annoying to have to maintain the list of names in so many places! Can we just dynamically add to __all__ like this, since anything exported at the builtin/__init__.py level should probably be public API anyway?

@adrn adrn requested a review from nstarman August 11, 2025 19:37
@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.84%. Comparing base (ef83e69) to head (3f5a10b).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #757   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files         158      158           
  Lines        5963     5965    +2     
=======================================
+ Hits         5715     5717    +2     
  Misses        248      248           

☔ 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.

@adrn adrn mentioned this pull request Aug 13, 2025
@adrn adrn added this to the v0.1 milestone Aug 13, 2025
@adrn adrn requested a review from Copilot August 13, 2025 23:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR alphabetizes the builtin potential list and simplifies the public API export mechanism by dynamically adding builtin potentials to __all__ instead of manually maintaining duplicate lists.

  • Sorts the __all__ list in builtin/__init__.py alphabetically for better maintainability
  • Replaces explicit import and __all__ entries with a dynamic approach using from ._src.builtin import *
  • Automatically extends the main __all__ list with builtin potentials to reduce duplication

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/galax/potential/_src/builtin/init.py Alphabetizes the __all__ list of builtin potential names
src/galax/potential/init.py Removes manual builtin imports/exports and dynamically adds them via wildcard import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

gNFWPotential,
)
from ._src.builtin import *
from ._src.builtin import __all__ as _builtin_all
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Using wildcard imports (from module import *) is generally discouraged as it makes it unclear what names are being imported and can lead to namespace pollution. Consider using explicit imports or importing the module and accessing attributes through it.

Suggested change
from ._src.builtin import __all__ as _builtin_all
from ._src.builtin import __all__ as _builtin_all
for _name in _builtin_all:
globals()[_name] = getattr(__import__(f"{__name__}._src.builtin", fromlist=[_name]), _name)

Copilot uses AI. Check for mistakes.
# isort: split
from ._src import register_funcs

__all__ = __all__ + list(_builtin_all)
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The expression __all__ = __all__ + list(_builtin_all) modifies __all__ after it's been defined, making the final exported API less obvious. Consider using __all__.extend(_builtin_all) for clearer intent, or define __all__ completely in one place.

Suggested change
__all__ = __all__ + list(_builtin_all)
__all__.extend(_builtin_all)

Copilot uses AI. Check for mistakes.
@nstarman
Copy link
Contributor

I like the idea of simplifying the __init__.py. But I think the public-facing one should have the statically defined list. This can be important for tools.

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.

2 participants