vscode autopep8无法格式化python代码问题解决
作者:ponponon
这篇文章主要为大家介绍了vscode autopep8无法格式化python代码问题解决,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
示例
import requests url='http://xxx:15672/api/queues/vobile-it?page=1&page_size=100&name=&use_regex=false&sort=messages&sort_reverse=true&pagination=true' response=requests.get(url) items:list[dict]=response.json()['items'] items
手动输入autopep8
上面的代码,死活无法用快捷键格式化,所以手动输入autopep8看看
╰─➤ autopep8 dev/rabbtimq_queues.py --in-place 130 ↵ Traceback (most recent call last): File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/bin/autopep8", line 8, in <module> sys.exit(main()) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 4548, in main results = fix_multiple_files(args.files, args, sys.stdout) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 4443, in fix_multiple_files ret = _fix_file((name, options, output)) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 4413, in _fix_file return fix_file(*parameters) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 3615, in fix_file fixed_source = fix_lines(fixed_source, options, filename=filename) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 3595, in fix_lines fixed_source = fix.fix() File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 618, in fix self._fix_source(filter_results(source=''.join(self.source), File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 562, in _fix_source modified_lines = fix(result) File "/Users/ponponon/.local/share/virtualenvs/crawler_console-J8uqt1Xz/lib/python3.10/site-packages/autopep8.py", line 766, in fix_e225 pycodestyle.missing_whitespace_around_operator(fixed, ts)) AttributeError: module 'pycodestyle' has no attribute 'missing_whitespace_around_operator'. Did you mean: 'whitespace_around_operator'?
懒得去管是哪个模块引起的问题了
先无脑升级第三方试试
─➤ pip install --upgrade -r requirements-dev.txt && pip install --upgrade -r requirements-prd.txt
升级之后,问题就解决了
以上就是vscode autopep8无法格式化python代码问题解决的详细内容,更多关于vscode autopep8格式化python的资料请关注脚本之家其它相关文章!