Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何修复:flake8/pyflakes将类之前的多行注释视为错误_Python_Emacs_Pyflakes_Flake8 - Fatal编程技术网

Python 如何修复:flake8/pyflakes将类之前的多行注释视为错误

Python 如何修复:flake8/pyflakes将类之前的多行注释视为错误,python,emacs,pyflakes,flake8,Python,Emacs,Pyflakes,Flake8,我将flake8与emacs一起使用。如果我以 # comment comment comment comment comment comment comment comment comment comment class Foo(object): pass 它说没有语法错误。但如果我把它包装成: # comment comment comment comment comment comment comment comment # comment comment class Foo(o

我将flake8与emacs一起使用。如果我以

# comment comment comment comment comment comment comment comment comment comment
class Foo(object):
    pass
它说没有语法错误。但如果我把它包装成:

# comment comment comment comment comment comment comment comment
# comment comment
class Foo(object):
    pass
我得到“E302预期2个空行,发现0”作为“类”行


这是虫子吗?可以通过配置设置来修复吗?

这个问题在这里,因为它在emacs站点上被标记为top,但实际答案是:

无论如何,这段代码很好:

class A:
    pass


# two empty lines above and comment comment comment comment
class B:
    """
    About class B
    """
这也很好:

class A:
    pass


# two empty lines above and a comment
# comment
class B:
    """
    About class B
    """
这将失败,
E302预期会找到2个空行1

class A:
    pass

# comment
# comment
class B:
    """
    About class B
    """

该错误是由类之间的一行引起的。也许,这就是你的问题所在

你为什么要在课前发表评论?如果它们属于该类,则它们应该是该类中的一员。如果没有,应该有空白来表示。在这种情况下,注释是实现细节,而不是类用户的注释。我明白了。一般情况:是的,您可以配置所需的警告,例如使用
#noqa
。有关您正在使用的工具,请参阅文档。你也可以扩展<代码> FLAKE8/CODE >如果必要的话,如果你认为这是一个bug,那么就向开发者提出来。