我遇到了几行与此类似的代码,但我不确定如何打破它:
blueprint = Blueprint(self.blueprint_map[str(self.ui.blueprint_combo.currentText())], runs=self.ui.runs_spin.text(), me=self.ui.me_spin.text(), pe=self.ui.pe_skill_combo.currentIndex())
Run Code Online (Sandbox Code Playgroud)
提前致谢
我决定在我的python代码中从制表符切换到空格.以前,如果我想在vim中缩进/取消一段代码,我会使用>>
或<<
命令.
我正在使用python的vimrc设置添加到我的~/.vimrc
:
source ~/.vimrc-python
Run Code Online (Sandbox Code Playgroud)
目前,似乎它将新选项卡设置为8个空格宽,当我阻止缩进/非缩进时,它将所有内容移动四个空格.
我怎么能得到一切以使它一致?
我正在尝试解决在向Firefox UI GitHub repo发出拉取请求后由Travis构建生成的PEP8错误.我已经能够使用pep8
库在本地重现这些错误.具体来说,我在一个超过99个字符限制的文件中有以下行:
Wait(self.marionette).until(lambda _: self.autocomplete_results.is_open and len(self.autocomplete_results.visible_results) > 1))
Run Code Online (Sandbox Code Playgroud)
它在运行时产生的错误pep8
由下式给出:
$ pep8 --max-line-length=99 --exclude=client firefox_ui_tests/functional/locationbar/test_access_locationbar.py
firefox_ui_tests/functional/locationbar/test_access_locationbar.py:51:100: E501 line too long (136 > 99 characters)
Run Code Online (Sandbox Code Playgroud)
该行Wait().until()
从Marionette Python客户端调用该方法.以前这条线实际上是两条不同的线:
Wait(self.marionette).until(lambda _: self.autocomplete_results.is_open)
Wait(self.marionette).until(lambda _: len(self.autocomplete_results.visible_results) > 1)
Run Code Online (Sandbox Code Playgroud)
回购经理建议我将这两行合并为一行,但这会延长结果行的长度,导致PEP8错误.
我可以将它改回原来的样子,但有没有任何格式化或缩进线的方法,这样就不会导致这个PEP8错误.
提前致谢.
这是需要缩短的行.
tree_top = os.path.abspath(os.path.expanduser(os.path.expandvars(sys.argv[1])))
Run Code Online (Sandbox Code Playgroud)
os.path,abspath
,os.path.expandvars
并os.path.expanduser
有较短的名称?我正在阅读PEP 8
,在导入部分,它说"标准库导入"放在库导入部分的顶部.我的问题是:我如何知道哪些库是"标准的"?即,我在哪里可以找到哪些库是"标准"的列表?
我想在我的 VS Code 编辑器上看到一条垂直线。有办法显示吗?如何启用此功能?
我已经安装了 pylint 和 pep8。它似乎工作正常。我只想在我的编辑器中看到这一行。
问题:PEP8: amiguous class definition 'I'
当我尝试定义 name 的类时,
为什么 PEP8 会发出警告I
?我找不到任何内置I
.
mwe.py:
class I:
pass
Run Code Online (Sandbox Code Playgroud)
评论:
class E
I
I
”远不是一个独特的搜索词PyCharm 2019.1.3 (Community Edition)
有没有办法配置 python 项目以忽略pycodestyle
项目方面的特定指令?
.pycodeignore
即在项目的根目录中添加一个文件,其中包含以下条目:
E302
E266
Run Code Online (Sandbox Code Playgroud)
ETC?
pep8 ×10
python ×10
class ×1
coding-style ×1
github ×1
import ×1
pycharm ×1
pycodestyle ×1
python-2.7 ×1
python-3.x ×1
vim ×1