-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Changes from all commits
b206619
c32988a
7a8aac8
69908d4
6ef969d
c39e9b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,21 @@ | |
; "current form" and not be surprised that it wasn't what you thought. | ||
(fn form-node? | ||
[node] | ||
(or (= "expression_statement" (node:type)) | ||
(= "import_statement" (node:type)) | ||
(= "import_from_statement" (node:type)) | ||
(= "with_statement" (node:type)) | ||
(= "function_definition" (node:type)) | ||
(= "for_statement" (node:type)) | ||
(= "call" (node:type)))) | ||
(log.dbg "form-node?: node:type =" (node:type)) | ||
(log.dbg "form-node?: node:parent =" (node:parent)) | ||
(let [parent (node:parent)] | ||
(if (= "expression_statement" (node:type)) true | ||
(= "import_statement" (node:type)) true | ||
(= "import_from_statement" (node:type)) true | ||
(= "with_statement" (node:type)) true | ||
(= "decorated_definition" (node:type)) true | ||
(= "for_statement" (node:type)) true | ||
(= "call" (node:type)) true | ||
(and (= "class_definition" (node:type)) | ||
(not (= "decorated_definition" (parent:type)))) true | ||
(and (= "function_definition" (node:type)) | ||
(not (= "decorated_definition" (parent:type)))) true | ||
false))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
(fn with-repl-or-warn [f opts] | ||
(let [repl (state :repl)] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Ohh good idea for a debug line, this will help diagnose some things.