Skip to content

[MNT] Fix string formatting and stacklevel for v2 model warnings.#2216

Open
Gitanaskhan26 wants to merge 2 commits intosktime:mainfrom
Gitanaskhan26:fix/warning-string-concatenation-spaces
Open

[MNT] Fix string formatting and stacklevel for v2 model warnings.#2216
Gitanaskhan26 wants to merge 2 commits intosktime:mainfrom
Gitanaskhan26:fix/warning-string-concatenation-spaces

Conversation

@Gitanaskhan26
Copy link

@Gitanaskhan26 Gitanaskhan26 commented Mar 20, 2026

Reference Issues/PRs

None (Standalone cleanup for warning messages noticed while browsing the v2 code).

What does this implement/fix? Explain your changes.

While reading through the v2 model base classes, I noticed a few warning messages were getting squished together due to missing trailing spaces in Python's implicit multi-line string concatenation.

This PR cleans those up so they render correctly for the end-user. Specifically, I:

  • Fixed the missing spaces between concatenated string literals (e.g., "implementationof" -> "implementation of", "betatesting" -> "beta testing", "somepatches" -> "some patches").
  • Fixed a quick typo ("unannouced" -> "unannounced") in _timexer.py.
  • Added stacklevel=2 to the warnings.warn() calls in these files. This ensures the warning correctly points to the user's actual script rather than the internal library code, which makes debugging much easier for them.

What should a reviewer concentrate their feedback on?

Very lightweight review! Just a quick sanity check on the string spacing and the stacklevel=2 additions across the modified files.

Did you add any tests for the change?

No new tests were added since this is strictly a string formatting and warning stacklevel fix. However, existing tests for DLinear v2 and TimeXer v2 continue to pass cleanly locally.

Any other comments?

All pre-commit hooks have been run, and ruff is perfectly happy with the line lengths on the modified warnings.

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG].
  • Added/modified tests (N/A — simple string formatting fix)
  • Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install. To run hooks independent of commit, execute pre-commit run --all-files

…del base classes

Fix garbled warning messages caused by missing trailing spaces in
Python implicit string concatenation across v2 model base classes.

Changes:
- Fix missing spaces between concatenated string literals in warning
  messages (e.g. 'implementationof' -> 'implementation of')
- Fix typo 'unannouced' -> 'unannounced' in TimeXer v2
- Add stacklevel=2 to all warn() calls so warnings point to user
  call site instead of internal library code

Files modified:
- pytorch_forecasting/models/base/_tslib_base_model_v2.py
- pytorch_forecasting/models/base/_base_model_v2.py
- pytorch_forecasting/models/timexer/_timexer_v2.py
- pytorch_forecasting/models/timexer/_timexer.py
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@5600398). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2216   +/-   ##
=======================================
  Coverage        ?   86.62%           
=======================================
  Files           ?      165           
  Lines           ?     9736           
  Branches        ?        0           
=======================================
  Hits            ?     8434           
  Misses          ?     1302           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.62% <ø> (?)
pytest 86.62% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@Gitanaskhan26 Gitanaskhan26 changed the title [BUG] Fix missing spaces in warning string concatenation across v2 model base classes [MNT] Fix string formatting and stacklevel for v2 model warnings. Mar 20, 2026
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