在VS-Code中格式化保存动作导入语句 [英] Formatting on save moves import statment in VS-Code

查看:48
本文介绍了在VS-Code中格式化保存动作导入语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Flask,并基于 Corey Schafer的Youtube教程.我使用VS-Code作为我的首选编辑器.

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.

在教程5中,他将他的应用程序拆分为一个包结构,当我这样做时,我遇到了一个问题.在我的设置中,我启用了"editor.formatOnSave":true ,而我使用的格式化程序是autopep8.现在,当我将一个导入语句从文件的顶部移至底部并保存时,格式化程序将其移回顶部.我猜是因为"E402-修复模块级别导入不在文件顶部"吗?

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'?

我试图用"python.formatting.autopep8Args"忽略它:[--ignore = E402] ,但是什么也没做.也许在这里您只能旋转文字错误,而E402只是一个文字错误,并且与格式无关?

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.

欢呼

推荐答案

@BrettCannon太棒了!这样就解决了.尝试了很长时间才能解决它,以至于我忘记了那些引号,却没有发现它们丢失了.

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

这篇关于在VS-Code中格式化保存动作导入语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆