Skip to content
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

Yapf formatter sometimes doesn't work #427

Closed
toplinuxsir opened this issue Dec 15, 2017 · 9 comments
Closed

Yapf formatter sometimes doesn't work #427

toplinuxsir opened this issue Dec 15, 2017 · 9 comments

Comments

@toplinuxsir
Copy link

Environment data

VS Code version: 1.9.0
Python Extension version: 0.9
Python Version: 3.6.1
OS and version: Debian linux 9.3

Actual behavior

Expected behavior

Steps to reproduce:

Logs

Output from Python output panel

Output from Console window (Help->Developer Tools menu)


/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] ApplicationInsights:Sender Array(1)
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
2/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] TextEditor is closed/disposed
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] ApplicationInsights:Sender Array(1)
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] ApplicationInsights:Sender Array(1)
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
5/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] TextEditor is closed/disposed
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
2/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] TextEditor is closed/disposed
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
2/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] TextEditor is closed/disposed
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
4/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
3/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249 [Extension Host] (node:18796) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:249
t._logExtensionHostMessage @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:2573
(anonymous) @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:2569
emitTwo @ events.js:106
emit @ events.js:194
process.nextTick @ internal/child_process.js:766
_combinedTickCallback @ internal/process/next_tick.js:73
_tickCallback @ internal/process/next_tick.js:104
@DonJayamanne
Copy link

DonJayamanne commented Dec 15, 2017

  • Please could you upload the file you are trying to format? (Or a sample file that doesn't work).
  • Does the file get formatted when you try to format it using the yapf cli
  • Finally how are you invoking the formatter?

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster area-formatting bug Issue identified by VS Code Team member as probable bug labels Dec 15, 2017
@toplinuxsir
Copy link
Author

toplinuxsir commented Dec 15, 2017

  1. Yes I use yapf from cli , It worked!
  2. I use the formatter when I save (set editor.formatOnSave=True) files

@DonJayamanne
Copy link

DonJayamanne commented Dec 15, 2017

Thanks, stripped the console output, you have already provided that. Please confirm there's nothing in the python output panel.
Thanks.

@DonJayamanne DonJayamanne added awaiting 1-verification and removed info-needed Issue requires more information from poster labels Dec 15, 2017
@toplinuxsir
Copy link
Author

@DonJayamanne
Yes, theres' nothing in the python output panel.

@toplinuxsir
Copy link
Author

toplinuxsir commented Dec 15, 2017

When yapf formmating not working , I create a task for yapf :

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "command": "/home/lhs/python-envs/barcodesysjobs/bin/yapf",
    //"command": "echo",
    //"isShellCommand": true,
    //"shell": true,
    "type": "process",
    //"args": ["${file}"],
    "args": [
        "-p",
        "--in-place",
        "--style",
        "{ based_on_style: google, indent_width:4 }",
        "${file}"
    ],
    //"showOutput": "always",
    "echoCommand": true,
    "presentation": {
        "reveal": "always",
        "panel": "new",
        "focus": true
    }
}

The task works ok .

@DonJayamanne
Copy link

What are your workspace settings in settings.json

@toplinuxsir
Copy link
Author

@DonJayamanne

{
    "python.pythonPath": "/home/lhs/python-envs/qfcenter/bin/python",
    // "python.formatting.formatOnSave": true,
    "python.formatting.provider": "yapf",
    "python.linting.lintOnSave": true,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Path": "/home/lhs/python-envs/barcodesysjobs/bin/flake8",
    "python.linting.pylintEnabled": false,
    "python.formatting.yapfPath": "/home/lhs/python-envs/barcodesysjobs/bin/yapf",
    "editor.lineHeight": 31,
    "python.formatting.yapfArgs": [
        "-p",
        "--style",
        "{ based_on_style: google, indent_width:4 ,  column_limit:79}"
    ],
    "editor.fontFamily": "'Fira Code Retina','Input Mono Condensed','Input Mono Compressed'",
    "editor.fontLigatures": true,
    "editor.fontSize": 18,
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.wordWrap": "on",
    "editor.wordWrapColumn": 80,
    "http.proxy": "",
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "/home/lhs/python-envs/qfcenter/bin/python",
        "perl": "perl",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt"
    }
}

@brettcannon brettcannon changed the title Yapf formatter sometime not working ! Yapf formatter sometimes doesn't work Dec 15, 2017
@toplinuxsir
Copy link
Author

@DonJayamanne
Mofied below two options from true to false

   "editor.formatOnPaste": false,
    "editor.formatOnType": false,

It seems works ok .

@DonJayamanne DonJayamanne self-assigned this Jan 22, 2018
@DonJayamanne
Copy link

Awesome. Thanks

@DonJayamanne DonJayamanne removed their assignment Jan 22, 2018
@DonJayamanne DonJayamanne reopened this Jan 22, 2018
@DonJayamanne DonJayamanne self-assigned this Jan 22, 2018
@DonJayamanne DonJayamanne added closed-fixed and removed bug Issue identified by VS Code Team member as probable bug labels Jan 22, 2018
@DonJayamanne DonJayamanne removed their assignment Jan 22, 2018
@brettcannon brettcannon added this to the January 2018 milestone Jan 29, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants