Formatting on save moves import statment in VS-Code

喜你入骨 提交于 2021-01-21 14:37:43

问题


I am learning flask and building a app based on Corey Schafer's Youtube tutorials. I'm using VS-Code as my editor of choice.

In tutorial 5 he splits his app into a package structure and when I do it I run into a problem. In my settings I enabled the "editor.formatOnSave": true and the formatter I use is autopep8. Now when I move one of my import statements from the top to the bottom of my file and save, the formatter moves it back to the top. I'm guessing its because of 'E402 - Fix module level import not at top of file'?

I tried to ignore it with the "python.formatting.autopep8Args": [--ignore=E402] but that did nothing. Maybe here you can only turn of lynting errors and E402 is only a lynting error and its not relevant for the formatting?

I hope you can help me disable or fix it.

Cheers


回答1:


@BrettCannon terrific! That fixed it. Tried so long to fix it that i forgot those quotes and didnt see that they were missing.



来源:https://stackoverflow.com/questions/53579109/formatting-on-save-moves-import-statment-in-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!