Giter Site home page Giter Site logo

Comments (8)

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@jesse-sony - hi, how did you get your binary yapf ? and you're using yapf.path settings, right ?

from vscode-extension-yapf.

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@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.

jesse-sony avatar jesse-sony commented on July 25, 2024

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.

jesse-sony avatar jesse-sony commented on July 25, 2024

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.

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@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.

jesse-sony avatar jesse-sony commented on July 25, 2024

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
image

And then I can just point vscode at my bat (or bash) file and everything works

from vscode-extension-yapf.

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@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.

jesse-sony avatar jesse-sony commented on July 25, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.