Add strict parameter to map() builtin#7405
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 selected for processing (1)
📝 WalkthroughWalkthroughPyMap gains a configurable strict mode stored atomically, accepted via constructor args, preserved in pickling (reduce/setstate), and enforced during iteration to detect and raise ValueError on input-length mismatches when enabled. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PyMap
participant PyIter as Iterator
participant VM as VirtualMachine
Caller->>PyMap: PyMap.new(iterables..., strict=bool)
PyMap->>PyMap: store strict (PyAtomic<bool>)
Caller->>PyMap: next()
PyMap->>PyIter: advance each input iterator
PyIter-->>PyMap: item or StopIteration / error
alt strict == true and length mismatch detected
PyMap->>VM: raise ValueError("map() argument ... is shorter/longer")
VM-->>Caller: propagate error
else no mismatch or strict == false
PyMap->>Caller: return next mapped item or StopIteration
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/poplib.py dependencies:
dependent tests: (1 tests)
[x] test: cpython/Lib/test/test_builtin.py (TODO: 19) dependencies: dependent tests: (no tests depend on builtin) [x] test: cpython/Lib/test/test_gc.py dependencies: dependent tests: (168 tests)
[x] lib: cpython/Lib/symtable.py dependencies:
dependent tests: (2 tests)
Legend:
|
moreal
left a comment
There was a problem hiding this comment.
Thank you for your first contribution!
youknowone
left a comment
There was a problem hiding this comment.
Thank you so much! and welcome to RustPython project
* Add strict parameter to map() builtin * Refactor map IterNext to match zip style
* Add strict parameter to map() builtin * Refactor map IterNext to match zip style
Summary by CodeRabbit
New Features
Bug Fixes