Skip to content

clean incomplete emissions constraint handler#332

Open
DavidLikesLearning wants to merge 2 commits into
TemoaProject:mainfrom
DavidLikesLearning:fixEmissionLimTypeError
Open

clean incomplete emissions constraint handler#332
DavidLikesLearning wants to merge 2 commits into
TemoaProject:mainfrom
DavidLikesLearning:fixEmissionLimTypeError

Conversation

@DavidLikesLearning
Copy link
Copy Markdown

@DavidLikesLearning DavidLikesLearning commented Jun 2, 2026

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 emitted during emission limit validation so placeholders are populated correctly.
    • No functional behavior changes; this yields clearer runtime warnings and more reliable diagnostic messages for operators and maintainers.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

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

Run ID: 80ae6b97-0dc3-4099-a822-e04dbcad7e3e

📥 Commits

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

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

Walkthrough

The logger.warning call in temoa/components/limits.py is changed to pass e and emission_limit as separate formatting arguments instead of as a single tuple, altering how the %s placeholders are filled in the warning message.

Changes

Emission Constraint Logging

Layer / File(s) Summary
Logger warning argument update
temoa/components/limits.py
The logger.warning call in the "no technology produces emission" branch now passes e and emission_limit as separate arguments to the logger instead of as a single tuple, affecting placeholder substitution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'clean incomplete emissions constraint handler' is vague and doesn't clearly describe the specific bug fix (a logging argument passing issue causing TypeError). Consider revising the title to be more specific about the fix, such as 'Fix TypeError in emissions constraint logger call' or 'Fix logger warning format in emission limit handler'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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
Copy link
Copy Markdown
Author

@DavidLikesLearning DavidLikesLearning left a comment

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

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