clean incomplete emissions constraint handler#332
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe logger.warning call in ChangesEmission Constraint Logging
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
temoa/components/limits.py
avoids string interpolation just in case
DavidLikesLearning
left a comment
There was a problem hiding this comment.
changed to preferred formatting for logging module
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 themsgpre-formatted string will ask for two things from the 1-tuple and crash with aTypeErrorlogger.warning(msg %(e, emission_limit))explicitly givesmsgthe elements it wants. Thenlogger.warningdoesn't mess with our tuple, it just sees a nice clean string with the values ofeandemission_limitalready incorporated.Summary by CodeRabbit