Skip to content

Do not coerce int properties if value already int#155

Open
axiom wants to merge 1 commit into
gmr:mainfrom
axiom:main
Open

Do not coerce int properties if value already int#155
axiom wants to merge 1 commit into
gmr:mainfrom
axiom:main

Conversation

@axiom

@axiom axiom commented May 19, 2026

Copy link
Copy Markdown

After upgrading from 2.0.1 to 3.0.1, I noticed that my logs contains lots of WARNING:rabbitpy.message:Coercing property priority to int lines, which is slightly annoying.

It seems to me that the cause is an unconditional coercion to int, even if the property value already is an integer--as it is in my case.

Here is a change that only does the int coercion if the value isn't an int already.

Hopefully this is okay.

Summary by CodeRabbit

  • Bug Fixes
    • Optimized integer property handling in message processing to skip unnecessary type conversions when values are already correctly typed, improving efficiency.

Review Change Stack

If (the priority) property already is an integer, skip the int coercion
and notably skip the warning about int coercion.

Add a trival test checking that int priority properties goes through
_coerce_properties unchanged.
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9f14acf-51d4-4188-adc7-49e77af15fc8

📥 Commits

Reviewing files that changed from the base of the PR and between f157a9b and a47b755.

📒 Files selected for processing (2)
  • rabbitpy/message.py
  • tests/test_message.py

📝 Walkthrough

Walkthrough

The Message._coerce_properties() method now includes a guard condition when handling AMQP int-typed properties, coercing only when the value is not already a Python int. A corresponding test verifies this behavior preserves integer priority values unchanged.

Changes

Integer property coercion fix

Layer / File(s) Summary
Integer coercion guard and test
rabbitpy/message.py, tests/test_message.py
_coerce_properties() adds an isinstance() check to skip coercion when an int property value is already a Python int. Test case confirms integer priority remains unchanged after coercion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit's tale of cleaner code,
Where ints stay int upon the road,
No coercion twice, no waste in sight,
Just one small guard makes logic right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: optimizing int property coercion to skip when value is already an int.
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.

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