-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add return annotation to __annotations__
last
#6071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add return annotation to __annotations__
last
#6071
Conversation
Functions like `functools.singledispatch` are sensitive to the order of items in the `__annotations__` map. CPython puts returns last.
WalkthroughThe change updates the Changes
Sequence Diagram(s)sequenceDiagram
participant Compiler
participant Parameters
participant Expr (Return Annotation)
Compiler->>Parameters: Iterate parameter annotations
loop For each parameter
Compiler->>Parameters: Compile annotation
end
alt If return annotation exists
Compiler->>Expr: Compile return annotation
end
Compiler-->>Compiler: Return total annotation count
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Files:
🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Thank you so much! To prevent regression, could you add a test about this? Adding the code described in the issue to |
Can do 🫡 |
Description
Functions like
functools.singledispatch
are sensitive to the order of items in the__annotations__
map. CPython puts return types last.Resolves #6068
Note: I'd prefer to include automated tests from CPython alongside this, but struggled. There are tests from Python 3.13.5's
test_importlib/
which will fail without commit, as they make use ofsingledispatch
that would serve to test this code change on every release.Test script
RustPython before
## CPython
RustPython after
Summary by CodeRabbit