-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add basic python client #408
Conversation
this seems like a bigger issue than I originally thought. Removing blank lines obviously can screw up multiline strings, but also, the python interpreter wants multiple lines between things like |
I've spent a bit of time playing around with the issue I described above and I think it may be a dead-end or at least a rabbit hole trying to get this to work with the basic This repo https://github.com/geg2102/nvim-python-repl has provided me with some inspiration for using |
fnl/conjure/client/python/stdio.fnl
Outdated
; sending a command is the result of the command. | ||
; Relevant docs: https://docs.python.org/3/library/sys.html#sys.displayhook | ||
(def update-python-displayhook | ||
(.. "import sys\n" |
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.
🐼 look at str.join
for multi line strings like this. Fennel also supports multi line strings out of the box, but with python indent it might get a bit messy.
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.
Noted :)
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.
..
also throws errors if it encounters a nil
, str.join
does not, it skips over it just like the Clojure implementation it's copied from. join
also pretty prints any non-string Lua data structures it encounters on the way.
I use str.join
everywhere instead of ..
unless I know I'm joining two simple strings and I KNOW they can not be anything else (i.e. they're not user input or from some other source).
I'll give the rest of the code a review soon :)
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.
Sounds good! If it wasn't clear, I do not think this PR is ready yet. Do you prefer to leave the PR open for discussion or keep the discussion in Discord until this is in a more complete state?
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.
Ah okay! No problem, just ping me when you're happy 😄 and either is totally fine. Can always have more back and forth in discord then go here for more review-like comments. Up to you! Whatever UX you prefer.
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.
Hi! I worked on the Common lisp client. If you need a hand with anything let me know, as I use python for my day job and would love to see this implemented!
If you haven't seen it already, feel free to join the discord! it could be nice to talk to other devs about it. There's no python channel yet but feel free to chat in the common-lisp channel. :D
https://discord.gg/5JC28a67
Hey @Dotrar! Yeah, it would be great to have more eyes on this and get some feedback. I'll hop on the discord |
595e09d
to
69d01e6
Compare
@Olical @Dotrar I think I'm ready for someone to take a look at this when you guys have some time. I updated the asciinema recording in the PR description if you want to take a look at how it's working. I ended up sticking with plain old A couple quirks about this implementation are:
|
Small update: I implemented |
Ohh I like the warning you added if you don't have TS set up. |
It works great! Nice one, everything "just worked" as expected. Code looks okay to me too, nothing stands out to me. I'm gonna just LGTM this and iterate on it if we ever need to. The whole point in isolating all client code into it's own modules / dirs allows us to just throw code in anyway since it won't interfere with other clients. So we can just try stuff out and iterate safely since it's only loaded if people try to use it. Thanks a lot! Now to sort out docs changes... |
Hey there!
This is my first pass at making a very basic python client for Conjure. I followed the Julia example pretty closely and made tweaks where appropriate, but it very much follows the same pattern.
This will probably need a fair bit of work to make it a robust solution for more people, but for my current use-case (building small one-off scripts for LeetCode challenges), it's working great so far! Most fun I've had writing Python code in a while.
I'm not sure if all the minor issues I listed below would be pre-requisites for merging this or if this can be useful for others before those are fully addressed. Either way, I thought I'd put this up and get some feedback on this.
What is working
With what I have here, I can:
Pretty much everything I've tested seems to be working at the moment
Here's a little demo:
https://asciinema.org/a/520309
![asciicast](https://camo.githubusercontent.com/4f89770abf704d1ac6fb799090340721e7bfda9d5c4a812f6f4fb8c93d6c539e/68747470733a2f2f61736369696e656d612e6f72672f612f3532303330392e706e67)
Things I still want to fix
exec
functionMore minor issues
doc-str
. I haven't looked into what is necessary to implement that, it may be really easy