Skip to content

clean incomplete emissions constraint handler - #332

Merged
jdecarolis merged 8 commits into
TemoaProject:unstablefrom
DavidLikesLearning:fixEmissionLimTypeError
Aug 31, 2026
Merged

clean incomplete emissions constraint handler#332
jdecarolis merged 8 commits into
TemoaProject:unstablefrom
DavidLikesLearning:fixEmissionLimTypeError

Conversation

@DavidLikesLearning

@DavidLikesLearning DavidLikesLearning commented Jun 2, 2026

Copy link
Copy Markdown

fixing bug #331

we've got
msg = "Warning: No technology produces emission '%s', though limit was specified as %s.\n"
logger.warning(msg, (e, emission_limit))

it's a 1 character fix. We want to pre-format the message string before feeding it to logger.warning.

logger.warning(msg, (e, emission_limit)) forces python to do the formatting, but it will make a 1-tuple of our 2-tuple: ((e, emission_limit),) and thus the msg pre-formatted string will ask for two things from the 1-tuple and crash with a TypeError

logger.warning(msg %(e, emission_limit)) explicitly gives msg the elements it wants. Then logger.warning doesn't mess with our tuple, it just sees a nice clean string with the values of e and emission_limit already incorporated.

Summary by CodeRabbit

  • Refactor
    • Improved formatting of warning messages shown when no technology produces a specified emission.
    • Warning details now display the relevant emission and limit values correctly, making runtime diagnostics clearer and easier to interpret.
    • No functional behavior changes were introduced.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f76145ae-4451-4d8a-bccc-e1e898284f64

📥 Commits

Reviewing files that changed from the base of the PR and between 2e082e2 and 99f42eb.

📒 Files selected for processing (1)
  • temoa/components/limits.py

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

The logger.warning call now passes e and emission_limit as separate formatting arguments.

Changes

Emission Constraint Logging

Layer / File(s) Summary
Logger warning argument update
temoa/components/limits.py
The warning call passes e and emission_limit separately instead of as a tuple.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 99f42

This localized change corrects warning-message formatting and prevents the incomplete emissions constraint path from failing during logging; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: idelder

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to the emissions constraint handler, which is the affected component. It does not identify the warning-formatting bug, but it remains related to the main change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@temoa/components/limits.py`:
- Line 944: The current code pre-formats the log message with `%`
(logger.warning(msg % (e, emission_limit))) which triggers Ruff G002; change it
to use lazy logging by passing the format string and arguments directly to
logger.warning (i.e., call logger.warning with msg and the variables e and
emission_limit as separate args) so the logger handles interpolation lazily and
Ruff G002 is resolved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bfcff8d5-e221-49d8-9569-31405d8bfb00

📥 Commits

Reviewing files that changed from the base of the PR and between e8bf144 and 606df13.

📒 Files selected for processing (1)
  • temoa/components/limits.py

Comment thread temoa/components/limits.py Outdated
avoids string interpolation just in case

@DavidLikesLearning DavidLikesLearning left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changed to preferred formatting for logging module

pre-commit-ci Bot and others added 4 commits June 15, 2026 16:57
updates:
- [github.com/astral-sh/uv-pre-commit: 0.11.19 → 0.11.21](astral-sh/uv-pre-commit@0.11.19...0.11.21)
- [github.com/astral-sh/ruff-pre-commit: v0.15.16 → v0.15.17](astral-sh/ruff-pre-commit@v0.15.16...v0.15.17)
updates:
- [github.com/astral-sh/uv-pre-commit: 0.11.21 → 0.11.23](astral-sh/uv-pre-commit@0.11.21...0.11.23)
- [github.com/astral-sh/ruff-pre-commit: v0.15.17 → v0.15.18](astral-sh/ruff-pre-commit@v0.15.17...v0.15.18)
@idelder

idelder commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Oh so the issue is just that the warning formatter is broken not the constraint itself? Yeah rebase and merge

@DavidLikesLearning

Copy link
Copy Markdown
Author

Oh so the issue is just that the warning formatter is broken not the constraint itself? Yeah rebase and merge

I am not sure if I clicked the right button. Let me know if Should do something else. Not super confident with git

@idelder

idelder commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Nah you're good that was just a note for joe

@DavidLikesLearning
DavidLikesLearning changed the base branch from main to unstable July 3, 2026 15:52
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
temoa/components/limits.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jdecarolis
jdecarolis merged commit 4db1eaf into TemoaProject:unstable Aug 31, 2026
13 of 14 checks passed
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.

3 participants