Pylint:意外的缩进错误-for循环

时间:2019-07-15 15:46:39

标签: python visual-studio-code

我尝试了几种不同的缩进“样式”,但是VSCode坚持认为第70行存在缩进错误。

为便于记录-标识符语句以及下面的所有内容在IDE中都进行了缩进。

for node in nodes:
identifier = node['id']
group = node['group']
# Checking if the node is immediately related to the viewer
if (group == viewer_group):
    note = {'source': identifier,

VSCode快照:
VSCode Snapshot

1 个答案:

答案 0 :(得分:2)

for之后需要缩进,直到循环结束

for node in nodes:
    identifier = node['id']
    group = node['group']
    # Checking if the node is immediately related to the viewer
    if (group == viewer_group):
        note = {'source': identifier, 

# code after loop
...