-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove AstNode
and AnyNode
#15479
Remove AstNode
and AnyNode
#15479
Conversation
|
They're mainly experimentations on my end but I never really had time to fully persuade them. The overall design with I do think it might be valuable to keep
|
What I'm eventually aiming for (WIP branch here) would be to use |
Putting this back to draft while I iterate on some follow-on patches |
a7d85b4
to
7434ed8
Compare
It's now just a wrapper around From, which we can call directly if we massage some trait definitions a bit.
This seems not to be used anywhere; all AST access seems to be through references, in particular `AnyNodeRef`.
7434ed8
to
da3221b
Compare
AstNode
traitAstNode
and AnyNode
This PR diff is much nicer with #15544 merged! This is ready for review again. I've also taken the opportunity to remove
I've kept |
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.
It's now also much easier to review. Thank you
While looking into potential AST optimizations, I noticed the
AstNode
trait andAnyNode
type aren't used anywhere in Ruff or Red Knot. It looks like they might be historical artifacts of previous ways of consuming AST nodes?AstNode::cast
,AstNode::cast_ref
, andAstNode::can_cast
are not used anywhere.cast_ref
isn't needed anymore, theRef
associated type isn't either.This is a pure refactoring, with no intended behavior changes.