Skip to content

Add @overload type signatures for series2seq and seq2series - #3178

Draft
authierj wants to merge 1 commit into
unit8co:masterfrom
authierj:jules/feature/typing
Draft

Add @overload type signatures for series2seq and seq2series#3178
authierj wants to merge 1 commit into
unit8co:masterfrom
authierj:jules/feature/typing

Conversation

@authierj

Copy link
Copy Markdown
Contributor

Description

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Summary

Improves static type inference for the two TimeSeries sequence-conversion helpers in
darts/utils/ts_utils.py:

  • Added @overload signatures to series2seq() so the return type is narrowed based on seq_type_out (SeriesType.SEQSequence[TimeSeries], SeriesType.SEQ_SEQSequence[Sequence[TimeSeries]]) and on whether ts is None.
  • Added @overload signatures to seq2series(), and corrected its implementation return annotation from TimeSeries | None to TimeSeriesLike | None (it returns the sequence unchanged when it holds more than one element).
  • Expanded the Returns docstring sections of both functions to document the None case and the fact that down-conversions only unwrap single-element sequences.

No runtime behavior changes — annotations and docstrings only.

Other Information

The overloads are currently grouped by confidence (GOOD ONES / OKAY / TO BE IMPROVED)
via inline comments. The broad catch-all overloads are needed until callers get their own
overloads, and can be narrowed in follow-up work.

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.96%. Comparing base (080b534) to head (2b01536).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3178      +/-   ##
==========================================
- Coverage   97.03%   96.96%   -0.07%     
==========================================
  Files         165      165              
  Lines       17951    17952       +1     
==========================================
- Hits        17418    17408      -10     
- Misses        533      544      +11     

☔ View full report in Codecov by Harness.
📢 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.

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.

1 participant