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 format sometimes doesn't work #418

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

Yapf format sometimes doesn't work #418

toplinuxsir opened this issue Dec 14, 2017 · 15 comments
Assignees
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@toplinuxsir
Copy link

Environment data

VS Code version: 1.8.1
Python Extension version: 0.8
Python Version: 3.6.2
OS and version: windows 10

Actual behavior

yapf format not working occasionlly

Expected behavior

format the python source code

Steps to reproduce:

Set vscode format when save
and modify python source code when save

Logs

Output from Python output panel

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


workbench.main.js:sourcemap:10 spawn ctags ENOENT: Error: spawn ctags ENOENT
	at exports._errnoException (util.js:1050:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
	at onErrorNT (internal/child_process.js:367:16)
	at _combinedTickCallback (internal/process/next_tick.js:80:11)
	at process._tickCallback (internal/process/next_tick.js:104:9)
e.onUnexpectedError @ workbench.main.js:sourcemap:10
workbench.main.js:sourcemap:9 [Extension Host] (node:440) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
t.log @ workbench.main.js:sourcemap:9
9workbench.main.js:sourcemap:9 [Extension Host] (node:440) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ workbench.main.js:sourcemap:9
10workbench.main.js:sourcemap:9 [Extension Host] (node:440) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
t.log @ workbench.main.js:sourcemap:9
t._logExtensionHostMessage @ workbench.main.js:sourcemap:9
(anonymous) @ workbench.main.js:sourcemap:9
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
workbench.main.js:sourcemap:9 [Extension Host] ApplicationInsights:Sender [Object]
t.log @ workbench.main.js:sourcemap:9
t._logExtensionHostMessage @ workbench.main.js:sourcemap:9
(anonymous) @ workbench.main.js:sourcemap:9
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
@toplinuxsir
Copy link
Author

The bug exist from version 0.5

@MikhailArkhipov MikhailArkhipov self-assigned this Dec 14, 2017
@brettcannon brettcannon added awaiting 1-verification area-formatting bug Issue identified by VS Code Team member as probable bug labels Dec 14, 2017
@brettcannon brettcannon changed the title Yapf format sometime not working !!!! Yapf format sometimes doesn't work Dec 14, 2017
@mkalakota
Copy link

I receive a different error for vscode version 1.19.1

TypeError: Cannot read property 'text' of undefined
	at HelpCompletionFeature.onEvent (C:\Users\Mouli Kalakota\.vscode\extensions\ms-vscode.powershell-1.5.1\out\src\features\HelpCompletion.js:34:100)
	at e.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:87:238)
	at e.$acceptDirtyStateChanged (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:432:782)
	at e.$acceptModelSaved (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:432:565)
	at t.e.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:516:87)
	at e._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:357:580)
	at e._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:357:270)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:356:206
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:358:204
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:85:988
	at e.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:87:218)
	at Socket.<anonymous> (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:135:717)
	at emitOne (events.js:96:13)
	at Socket.emit (events.js:191:7)
	at readableAddChunk (_stream_readable.js:178:18)
	at Socket.Readable.push (_stream_readable.js:136:10)
	at Pipe.onread (net.js:560:20)

@MikhailArkhipov
Copy link

Appears to be PowerShell extension judging from
**ms-vscode.powershell-1.5.1**\out\src\features\HelpCompletion.js
You may want to report it at https://github.com/PowerShell/vscode-powershell

@MikhailArkhipov
Copy link

@toplinuxsir - is it broken occasionally at any time or is it not working for some time after opening first Python file? The latter is because it actually takes a few seconds for the extension to load (VSC keeps UI accessible) - for example, Format Document command may not be available in context menu right after the file is opened.

@MikhailArkhipov MikhailArkhipov added info-needed Issue requires more information from poster and removed awaiting 1-verification labels Jan 8, 2018
@bcatubig
Copy link

I've noticed this issue as well when running in a virtualenv. My vscode python interpreter is defined and auto-format on save is set to true

Seems to be random when it works and when it doesn't. Is there any way to catch log output for the autoformat event?

@brettcannon
Copy link
Member

@bcatubig anything we log goes to the Output window (found under View). If you want to be truly daring/helpful, you could instrument your own build of the extension to try and catch the failure (if you need help instrumenting, let us know and we can try and point you at the right spot).

@bcatubig
Copy link

Hey @brettcannon,

I've found that by removing python.formatting.autopep8Args from my vs code config, autopep8 starts working again. It seems to stop working when this is defined.

Here is what I was using

    "python.formatting.autopep8Args": [
        "--experimental",
        "--max-line-length 120",
    ],

@brettcannon
Copy link
Member

@bcatubig could you try it again without the --experimental line but with the --max-line-length 120? It would be good to know if it's purely the --experimental flag that breaks things.

@bcatubig
Copy link

bcatubig commented Jan 17, 2018

@brettcannon ,

I receive errors with the following settings

"python.formatting.autopep8Args": [
        "--max-line-length 120",
    ]

here is the log from Output

Formatting with autopep8 failed.
Command failed: autopep8 --max-line-length 120 --diff --diff --diff /Users/brandon/code/test.py
usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
                [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                [--experimental] [--exclude globs] [--list-fixes]
                [--ignore errors] [--select errors] [--max-line-length n]
                [--line-range line line]
                [files [files ...]]
autopep8: error: unrecognized arguments: /Users/brandon/code/test.py

@DonJayamanne
Copy link

@bcatubig Please could you try with the following settings:

"python.formatting.autopep8Args": [
        "--max-line-length" , "120",
    ]

@bcatubig
Copy link

bcatubig commented Jan 17, 2018

@DonJayamanne That seems to have done the trick. autopep8 works now without error.

@brettcannon
Copy link
Member

@toplinuxsir @mkalakota do either of you happen to have custom yapf configuration settings in your settings.json file(s)?

@DonJayamanne
Copy link

Summarizing:

@mkalakota Please could you confirm you are still experiencing this issue.

@mkalakota
Copy link

@brettcannon No, I do not have any custom yapf configuration

@DonJayamanne Yes, it works now. Although, I'm not sure which update resolved the issue, vscode or the plugin

@DonJayamanne
Copy link

Thanks for getting back

@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.
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

6 participants