-
Notifications
You must be signed in to change notification settings - Fork 2
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
efficient formatting #25
base: main
Are you sure you want to change the base?
efficient formatting #25
Conversation
I've put this fork into a template -- except I realised that the pyright-extended used in repls is actually outdated and uses an old version of |
3ad488d
to
92722e9
Compare
Hey! Thanks for the contribution. Can we split this into two PRs?
We also looked at two internally but didn't find a way to pass config in via flags but using WASM is a nice way to get around that! Feel free to ping me for a review once you do that :) |
@jackyzha0 not sure how to go about splitting it up: adding tab support in |
For the first part, I'm looking for just a PR to edit the CLI flags passed to yapf to respect tabs without all the WASM-ed module stuff. As for optimized yapf vs ruff, let's just go with Ruff and I can review that one separately (this should also include the tab formatting option that the first PR includes but for ruff) The reason is that it'll likely take a few rounds of back and forth to while we review the latter PR but I think it's important to get a working patch in for tab formatting. |
to be clear, you mean the napi->cpython FFI stuff? |
I don't see any usages of napi ffi in your PR, just |
by that I mean the use of |
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.
theres a lot of package changes (esp at the root level), can you make sure your package-lock changes are scoped to your changes?
This comment has been minimized.
This comment has been minimized.
55ce798
to
3f6ede0
Compare
add tabs support too fixed! actually fixed now bruh I'd accidentally deleted the newer clone switch to Ruff for better perf Revert "switch to Ruff for better perf" This reverts commit 76d9c8e. fix newText bug in yapf option
60cca17
to
6ea6f08
Compare
This comment has been minimized.
This comment has been minimized.
6ea6f08
to
406ebb3
Compare
This comment has been minimized.
This comment has been minimized.
406ebb3
to
cce5cdd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Hey there! In an effort to get some confidence around changes like this I added some LSP tests in #32 and #33 which cover completion, linting, and formatting. I know this PR has been languishing for a while, but I think there's actually either a bug in the upstream $ mkdir python_workspace
$ echo 'print("hello")' > python_workspace/main.py
$ node packages/pyright/dist/pyright.js ./python_workspace/
.../python_workspace/main.py
.../python_workspace/main.py:1:1 - error: "print" is not defined (pyright[reportUndefinedVariable])
1 error, 0 warnings, 0 informations Additionally, in order to test this PR I had to delete
from To run the new test suite, |
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.
I think this is moving in the right direction, but it can't be merged as is unfortunately. Going to mark this as "Request changes," but I'm also happy to either close this out due to the upstream bug(s?) or just switch to invoking ruff
on the CLI instead of using the WASM bundle.
Please just let me know how you'd like to proceed, I'd like to get this in!
I'd got rid of the |
ruff as formatter would be really great. are there any news on this? |
Try my template. To keep the repl updated properly with the latest features from the replit python module, |
Switch to
ruff
, which is much faster thanyapf
-- even though it can't tell whether the contents of the file have changed, causing extra IO/processing in the case they haven't, it's unbeaten byyapf
in my tests. Or revert 3f6ede0 for the option which still usesyapf
but without spawning an executable each time.Also ~fixes https://ask.replit.com/t/replit-randomly-sets-all-tab-indententations-to-double-spaces-despite-preferences/57047.
There's a replit issue that indent disappears on format when the tab preference from the file settings differs from the user settingsI noticed it was because I'd been passing a tuple tonewText
instead of a string. But still, it's kind of a replit issue for not validating the response and causing crazy behaviour.