-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Use PyStrRef for TypeAliasType name #6203
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
Use PyStrRef for TypeAliasType name #6203
Conversation
WalkthroughAdds runtime validation ensuring TypeAliasType names are Python strings and changes the internal TypeAliasType.name field from Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Intrinsic Handler (frame.rs)
participant Typing as TypeAliasType (typing.rs)
participant VM as VirtualMachine
Caller->>Typing: provide name (PyObjectRef) and type_params, value
Typing->>Typing: downcast name -> PyStr
alt downcast succeeds
Typing->>Typing: construct TypeAliasType{name: PyStrRef, type_params, value}
Typing-->>Caller: return TypeAliasType instance
else downcast fails
Typing-->>Caller: raise TypeError("TypeAliasType name must be a string")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
youknowone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing!
This MR changes
TypeAliasTypeso that it uses aPyStrRefobject for itsnamefield instead of aPyObjectRef.Previously, the
namefield was a PyObjectRef. Although PyObjectRef is flexible, using a more specific type, like PyStrRef, improves transparency and type safety.Changes include:
TypeAliasType.namefromPyObjectReftoPyStrRef.TypeAliasType::new()and__name__getter to handlePyStrRef.vm/src/frame.rsvm/src/stdlib/typing.rsto enforce that the
TypeAliasTypename is a string.nameis now aPyStrRef, therepr_strimplementation forTypeAliasTypewas simplified by usingPyStrRef::as_str()directly.Summary by CodeRabbit