Skip to content

refactor(aggregation): Make NashMTL and CAGrad always importable#679

Open
ValerianRey wants to merge 2 commits into
mainfrom
refactor/optional-deps-mixin
Open

refactor(aggregation): Make NashMTL and CAGrad always importable#679
ValerianRey wants to merge 2 commits into
mainfrom
refactor/optional-deps-mixin

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented May 11, 2026

Summary

  • Add _WithOptionalDeps mixin to _mixins.py: subclasses declare _REQUIRED_DEPS and _INSTALL_HINT; __init__ raises ImportError with a clear install message if any dep is missing
  • CAGradWeighting and _NashMTLWeighting now inherit _WithOptionalDeps first, so the check fires at instantiation rather than at import time
  • CAGrad, CAGradWeighting, and NashMTL are now unconditionally importable and listed in __all__
  • Tests updated to use pytest.importorskip (the standard pattern) instead of a manual try/except ImportError guard
  • Add changelog entry

🤖 Generated with Claude Code

Add _WithOptionalDeps mixin that raises ImportError at instantiation time
when optional dependencies are missing, replacing the module-level guard
that previously prevented import altogether.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ValerianRey ValerianRey requested review from a team and PierreQuinton as code owners May 11, 2026 15:34
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ValerianRey ValerianRey added package: aggregation cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements labels May 11, 2026
@ValerianRey
Copy link
Copy Markdown
Contributor Author

@PierreQuinton IMO this is ready. You can merge if it helps for the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant