相关疑难解决方法(0)

vscode autopep8 allow statements before imports

I'm using vscode with the python plugin and autopep8 with

"editor.formatOnSave": true.

I have local packages I need to import, so I have something like

import sys
sys.path.insert(0, '/path/to/packages')
import localpackage
Run Code Online (Sandbox Code Playgroud)

but when I save, vscode/autopep8 moves all import statements before code, so python can't find my local package.

import sys
import localpackage
sys.path.insert(0, '/path/to/packages')
Run Code Online (Sandbox Code Playgroud)

how can I tell vscode/autopep8 that it's okay to put a statement before imports, or is there a more correct way of importing local …

python autopep8 visual-studio-code vscode-settings

8
推荐指数
2
解决办法
1742
查看次数