| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughThe changes introduce stricter argument validation to the object.__new__ method in the object builtin, aligning its behavior with CPython. Additionally, a formal constructor with argument validation is implemented for TypeAliasType in the typing module, and the representation logic is unified using the Representable trait. The NodeAst type in the AST module gains a custom constructor implementing the Constructor trait with a specialized slot_new method. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant VM
participant PyBaseObject
participant PyType
Caller->>VM: Call object.__new__(type, *args, **kwargs)
VM->>PyType: Check __new__ and __init__ methods
alt Arguments passed
alt Custom __new__ or __init__
VM->>PyBaseObject: Allow construction
else Base __new__ and __init__
VM->>Caller: Raise TypeError
end
else No arguments
VM->>PyBaseObject: Proceed with construction
end
sequenceDiagram
participant Caller
participant VM
participant TypeAliasType
Caller->>VM: Call TypeAliasType.__new__(cls, name, value, type_params=...)
VM->>TypeAliasType: Validate argument count and types
alt Argument validation fails
VM->>Caller: Raise TypeError
else Validation passes
VM->>TypeAliasType: Create instance
TypeAliasType-->>Caller: Return instance
end
sequenceDiagram
participant Caller
participant VM
participant NodeAst
participant BaseObject
Caller->>VM: Call NodeAst.__new__(cls, *args, **kwargs)
VM->>NodeAst: slot_new creates base object with dict if needed
NodeAst->>NodeAst: Call __init__ with args
NodeAst-->>Caller: Return initialized instance
Estimated code review effort
Suggested reviewers
Poem
📜 Recent review details Configuration used: .coderabbit.yml Reviewing files that changed from the base of the PR and between 2c7692b and 09c340a. ⛔ Files ignored due to path filters (3)
Instructions used from: Sources:
Learnt from: youknowone PR: RustPython/RustPython#5945 File: vm/src/stdlib/typing.rs:132-136 Timestamp: 2025-07-11T07:16:06.225Z Learning: In Python 3.12, TypeAliasType's __repr__ method returns just the alias name as a string (e.g., repr(A) returns 'A'), not the "<TypeAliasType AliasName>" format. This applies to type aliases created with the `type` statement syntax. Learnt from: CR vm/src/stdlib/ast/python.rs (3)✨ Finishing Touches
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 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit