Skip to content

typing(aggregation): Fix Literal attribute typing#549

Merged
ValerianRey merged 2 commits intomainfrom
fix-typing-literal-string
Feb 2, 2026
Merged

typing(aggregation): Fix Literal attribute typing#549
ValerianRey merged 2 commits intomainfrom
fix-typing-literal-string

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

  • typing(aggregation): Add SUPPORTED_SOLVER type alias
  • Fix Literal automatic type widening

When an attribute is a Literal["something", "something else"], it's important to type both the parameter value of the constructor and the attribute itself in the constructor. Before, we only typed the parameter value. When doing that, the attribute is considered as a string that is initialized at "something" or "something else", but that may change in the future to "even something else". So it's just considered as a string in other methods, not as a Literal["something", "something else"]. This only happens with Literals of strings, so we don't need to do that for every attribute.

This fixes 3 errors reported by Pylance.

Also create TypeAlias SUPPORTED_SCALE_MODE (forgot to separate commits)
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/torchjd/aggregation/_aligned_mtl.py 100.00% <100.00%> (ø)
src/torchjd/aggregation/_dualproj.py 100.00% <100.00%> (ø)
src/torchjd/aggregation/_upgrad.py 100.00% <100.00%> (ø)
src/torchjd/aggregation/_utils/dual_cone.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ValerianRey ValerianRey added the cc: typing Conventional commit type for improvements to typing. label Feb 1, 2026
Copy link
Copy Markdown
Contributor

@PierreQuinton PierreQuinton left a comment

Choose a reason for hiding this comment

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

Nice

@ValerianRey ValerianRey merged commit 7d30162 into main Feb 2, 2026
16 checks passed
@ValerianRey ValerianRey deleted the fix-typing-literal-string branch February 2, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: typing Conventional commit type for improvements to typing. package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants