Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 20, 2026

Summary by CodeRabbit

  • New Features

    • Introduced placeholder support for functools.partial, enabling you to skip positions when creating partial function applications.
    • Added __annotations__ and __annotate__ attribute support to classmethod and staticmethod decorators.
    • Enhanced functools.partial with descriptor protocol support.
  • Improvements

    • Updated functools.reduce argument handling for improved flexibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This pull request adds annotation attribute support to classmethod and staticmethod, refactors the reduce function signature with a new struct-based approach, and introduces placeholder support for functools.partial with counting, validation, and argument substitution capabilities.

Changes

Cohort / File(s) Summary
Spell Checker Dictionary
.cspell.dict/cpython.txt
Added new dictionary entry phcount for spell checker recognition.
Annotation Support
crates/vm/src/builtins/classmethod.rs, crates/vm/src/builtins/staticmethod.rs, crates/vm/src/builtins/type.rs
Extended annotation handling with new getters/setters for __annotations__ and __annotate__ attributes on classmethod and staticmethod; updated type's set___annotate__ to accept PySetterValue instead of Option<PyObjectRef> for consistent error handling.
Functools Enhancements
crates/vm/src/stdlib/functools.rs
Introduced placeholder mechanism for functools.partial with new _PlaceholderType class and Placeholder singleton; refactored reduce function to use ReduceArgs struct with tri-state initial value handling; enhanced PyPartial with GetDescriptor implementation, phcount field, and logic for placeholder counting, validation, and substitution in nested partials.

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Annotations now dance on methods both static and bound,
Placeholders hop through partial's rounds,
With phcount tallied and validation sound,
Reduce takes a structured ground—
Our VM springs forth with functional delight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: implementing new functools features (placeholder support, descriptor behavior for PyPartial, enhanced partial handling) and updating functools-related code.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@youknowone youknowone marked this pull request as ready for review January 20, 2026 08:53
@youknowone youknowone merged commit 0f28d4e into RustPython:main Jan 20, 2026
13 checks passed
@youknowone youknowone deleted the functools branch January 20, 2026 10:18
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