paetzke / py-yapf.el Goto Github PK
View Code? Open in Web Editor NEWUse yapf to beautify a Python buffer
License: GNU General Public License v3.0
Use yapf to beautify a Python buffer
License: GNU General Public License v3.0
Doesn't recognize python syntax.
for row in list(X):
add_values = add_feature(row.items())
row = {**row, **add_values}
if row and add_values are dictionaries, this is valid syntax. py-yapf doesn't think it is. This might be upstream in yapf?
i have the
Error: (error "invalid rcs patch or internal error in py-yapf-bf--apply-rcs-patch")
when run py-yapf-buffer
on any python file
i am using windows and emacs 24.4
i checked the source code of py-yapf.el but could not figure out why :(
yapf can be very slow on large files. Maybe an option to only reformat the changed region, because it's not really make sense to reformat a reformated file everytime it saves
Not sure if this is still being maintained, but I wanted to echo a few issues I had to correct to get an error message to show up properly on py-yapf-buffer in cases where yapf fails. Currently it simply says 'buffer is already yapfed' if anything goes wrong. Some of these have been echoed elsewhere but I found more than one issue so I'll list them all here.
Firstly, the if-statement determining whether to print a success/unchanged message as opposed to an error message incorrectly looks for a non-zero return value from the executable for its success case and also calls ignore-return-code as a function though it is a variable.
so this:
(if (or (funcall executable-call errbuf tmpfile)
(ignore-return-code))
should be this:
(if (or (zerop (funcall executable-call errbuf tmpfile))
ignore-return-code)
Furthermore, the actual call to that function is passing 't' for ignore-return-code. To get errors to show up this needs to be nil.
so this:
(defun py-yapf--call ()
(py-yapf-bf--apply-executable-to-buffer "yapf" 'py-yapf--call-executable nil "py" t))
should be this:
(defun py-yapf--call ()
(py-yapf-bf--apply-executable-to-buffer "yapf" 'py-yapf--call-executable nil "py" nil))
Hope this is useful. Happy to do a PR if this project is still being maintained...
see issue
They say the bug should be reported upstream, so I came here.
Sometimes yapf might be installed in a path that is not in $PATH. I don't actually know if this is what is currently preventing py-yapf from working for me, but regardless, it would be cool if I could set its path through customize.
Thank you for this excellent module!
I just have a suggestion: if there are any python syntax errors that occur during formatting, we currently simply get the message "Buffer is already yapfed". Instead of that, I believe it would be helpful to see these syntax errors. Therefore, I suggest this following patch, or something similar ...
--- py-yapf.el.orig 2017-11-18 12:36:18.017017290 -0500
+++ py-yapf.el 2017-11-18 12:36:27.086994492 -0500
@@ -139,7 +139,7 @@
(if (zerop (call-process-region (point-min) (point-max) "diff" nil
patchbuf nil "-n" "-" tmpfile))
(progn
- (kill-buffer errbuf)
+ (switch-to-buffer errbuf)
(pop kill-ring)
(message (format "Buffer is already %sed" executable-name)))
What do you think?
yapf will normally look in directories upwards to see if it can find information in the [yapf]
section in setup.cfg or the [yapf]
section in .yapf.style. Because py-yapf operates on a file in /tmp
, this settings are not respected.
It would be convenient if py-yapf would operate as if it were changing the file that a buffer represents.
Each time after applying py-yapf-buffer
, some top history of kill-ring
got removed.
Hello, when installing through melpa I got the following compilation warning:
py-yapf.el:166:1:Warning: the function `ignore-return-code' is not known to be defined.
I think the warning is legit.
I find this mode is not compatible with the following configuration. A error occurs when saving.
(setq python-shell-virtualenv-path "/home/mike/.virtualenvs/python3")
Without the upper configuration and using pyenv
to activate virtualenv, py-yapf
woks nice.
I can't fix this problem.
In general, it would be really cool if py-yapf
could install yapf
automatically on demand.
We could limit the side-effects of this operations by executing it in a virtual environment. This is a common strategy for packages like jedi
, anaconda-mode
and others. See the way anaconda-mode
does it here.
When this backdoor open it leaves the integration variable and allows a hacker to clone and steal a person identity and accounts and inables apps. In the wanlsn
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.