itertools: fix count() repr to show float step 1.0#8261
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesCount representation
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_itertools.py (TODO: 6) dependencies: dependent tests: (56 tests)
Legend:
|
moreal
left a comment
There was a problem hiding this comment.
Hello, it looks like your changes correspond to these lines:
Everything seems to pass the tests on my local machine (cargo run -- -m test test_itertools -m test_count_with_step -v), so I'm leaving an approval. Thanks for your contribution!
However, the CI is currently failing. I believe rebasing onto the latest main branch should resolve this issue.
Assisted-by: Claude Code:claude-opus-4-8
d9f76ac to
51b83c4
Compare
|
Thanks for the review and approval! 🙏 |
Summary
itertools.count()'s__repr__omitted the step when it equalled1, butCPython omits the step only for the integer
1— a float step of1.0should still be shown.
CPython's
count_reprskips the step only when it is aPyLongequal to1,so a float such as
1.0is still shown. The repr now omits the step only when itis exactly the integer
1(checked via both theinttype and value). Alsounmarks
test_count_with_step, which now passes.Verified locally:
cargo run --release -- -m unittest -v test.test_itertools.TestBasicOps.test_count_with_step->okcargo run --release -- -m test test_itertools-> SUCCESS (run=137, skipped=22)Assisted-by: Claude Code:claude-opus-4-8
Summary by CodeRabbit
stepvalue is now omitted only when it is exactly the integer1; other values and types remain explicitly shown for accurate representations.