Skip to content
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

Improve evaluation of class, decorated class, and decorated function definitions in Python with examples #618

Merged
merged 6 commits into from
Nov 17, 2024

Conversation

russtoku
Copy link
Contributor

Improved evaluation with <localleader>ee for class definitions and decorated class and function definitions in the Python client. Added some representative code for these cases to sandbox.py.

(= "for_statement" (node:type))
(= "call" (node:type))))
(log.dbg "form-node?: node:type =" (node:type))
(log.dbg "form-node?: node:parent =" (node:parent))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh good idea for a debug line, this will help diagnose some things.

(not (= "decorated_definition" (parent:type)))) true
(and (= "function_definition" (node:type))
(not (= "decorated_definition" (parent:type)))) true
false)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I assume this is inspired by the Julia client changes? Discovering that :InspectTree thing has made this a lot easier to reason about thankfully.

Not sure if we explicitly need to return true or false here though, I feel like we can get away with truthy and falsy. But if this is easier to reason about or you had issues without explicit boolean return values then this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I took inspiration from your changes to the Julia client while working on trying to upgrade an ancient Django project from version 1.9.

I was having some trouble getting the evaluation of classes and decorated classes/functions. In anger, I just did the simplest thing to keep me from confusing myself.

@Olical Olical merged commit c39e9b7 into Olical:main Nov 17, 2024
3 checks passed
@Olical
Copy link
Owner

Olical commented Nov 17, 2024

Tried it out locally and it works wonderfully, thanks! This tree sitter system is working pretty well 😄

@russtoku
Copy link
Contributor Author

Thanks for making Conjure and making all of this possible!

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.

2 participants