Comments (8)
@jesse-sony - hi, how did you get your binary yapf ? and you're using yapf.path
settings, right ?
from vscode-extension-yapf.
@jesse-sony - I reproduct this issue just both yapf bundled and in location in windows. And I confirm that is yapf built-in issue. execute type xx.py | yapf
in windows cmd can verity it. Cause I use stdin and stdout not yapf in-place, I can't fix it by my side, I will issue it to google/yapf
repo and release it when yapf resolve it.
from vscode-extension-yapf.
doesn't seem like it matters, but yes we're using yapf.path
and we built our own yapf package which we distribute internally.
If I have some time I'll poke around in the yapf internals and see if I can figure out what is happening. My initial thought was the Windows shell was stripping it out, but doing type test1.py > test2.py
does not remove it, so it does somehow seem to be related to how yapf is reading from stdin
from vscode-extension-yapf.
Looks like you pushed up a PR to fix it. I merged it into our branch of yapf and it is working. thank you!
from vscode-extension-yapf.
@jesse-sony - it's nice that you have your own yapf replica can merge this PR priority. But it seems you didn't use yapf.path
successful cause I will do something like this PR to google/yapf
on the extension side. Could you give me a rough idea of how you build a binary package then I can reproduct the same situation for me and comfirm what's happened here. cause google/yapf
didn't provide a offical tutorial to build a yapf binary.
from vscode-extension-yapf.
So I just rolled my own executable. I put all the YAPF code, the third_party libraries that are part of the YAPF repo, and all the dependencies into a directory structure and then wrote a little bash script to set the python path and run it (or bat script on windows).
So on windows, my launcher looks like
@echo off
PUSHD %~dp0
setlocal
cd /D %~dp0
set CURRENTPATH=%cd%
set ROOTDIR=%CURRENTPATH%\..
POPD
set PYTHONPATH=%ROOTDIR%;%ROOTDIR%\third_party
python.exe -m yapf %*
where my executable lives in a bin
directory that is a part of the yapf bundle.
Overall, my directory structure looks like
And then I can just point vscode at my bat (or bash) file and everything works
from vscode-extension-yapf.
@jesse-sony - thanks so much. I reproduct it through this approach. The reason is windows stdin buffer will auto replace \n
to \r\n
, so altought I already replace \r\n
to \n
, yapf will still get \r\n
raw. And if I don't do that, don't replace \r\n
to \n
, windows stdin buffer will change it to \r\r\n
then raise a python syntax error. Friendly to Windows users but Windows developer. In short, the only way to fix it is like the PR I issue to google/yapf
. Thanks for your help again.
from vscode-extension-yapf.
@EeyoreLee Thank YOU so much for the quick fix. We can close this ticket now, because I don't think there is anything else to be done on the plugin side.
from vscode-extension-yapf.
Related Issues (20)
- yapf: input filenames did not match any python files - No formatting done. HOT 2
- Format Selection is formatting the entire file HOT 5
- "ALLOW_MULTILINE_DICTIONARY_KEYS" flag no longer working HOT 1
- Something has gone awry with extension installed on Remote HOT 1
- [Feature Request] I hope to add a command to generate a yapf configuration file. HOT 1
- Newline is added to empty files causing PEP8 warning W391 HOT 3
- Path to .style.yapf HOT 5
- Yapf formatter with devcontainers not sticking HOT 3
- Range Formatting HOT 6
- Trailing empty line added to end of file / notebook cell HOT 4
- Python 3.7 is not supported HOT 2
- Formatting will be break for jupyter on `FormatOnType` mode if there are some magic function
- The "yapf" extension is configured to format programs, but not "Python"-files. HOT 6
- Cannot start server HOT 3
- Cannot handle new 3.12 f-strings, hangs up completely HOT 6
- Formatter is constantly formatting HOT 5
- The new version format: {year}.{month}.1{day}{hour}{minute}{second} HOT 1
- Yapf formatting on type instead of on save HOT 4
- Keep getting the message "there is no formatter for 'python' files installed" HOT 3
- SyntaxError for a Python 3.7 conda environment HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-extension-yapf.