"SublimeAutoPep8: some issue(s) were not fixed"如E501

"SublimeAutoPep8: some issue(s) were not fixed" such as E501

我在 Python 中收到软警告:

SublimeAutoPep8: some issue(s) were not fixed:
File "/Library/WebServer/dir/dir/filename.py", line 11: not fixed E501
File "/Library/WebServer/dir/dir/filename.py", line 33: not fixed E501

我目前的AutoPep8.sublime-settings是:

{
    "format_on_save": true,
     "max-line-length": 100,
}

我尝试在 Preferences.sublime-settings 中添加以下配置:

    "pep8": {
        "@disable": false,
        "args": [],
        "excludes": [],
        "ignore": [ "E251", "W291", "E501" ],
        "max-line-length": null,
        "select": ""
    },

不过好像不对。

我应该怎么做才能忽略这些警告?谢谢!

首先,你不应该在 Preferences.sublime-settings 中添加你的 AutoPep8 设置,而是应该将它们全部添加到 AutoPep8.sublime-settings 文件中,该文件应该位于你的 Sublime Text User 配置目录中。

其次,我认为您可能混淆了 2 个不同的 Sublime Text 包的设置,它们是 Auto​PEP8 and Python PEP8 Autoformat. Given the warning message you mention it seems reasonable to assume you installed AutoPep8 but the settings you show are a combination of the 2 packages, see the default AutoPep8.sublime-settings file and the default pep8_autoformat.sublime-settings 文件。这两个包都有一个 ignore 设置,但是 Python PEP8 Autoformat 包需要一个字符串列表,这是你使用的,而 AutoPep8 包需要一个逗号分隔值的字符串,这是我觉得你应该用过。

您应该能够使用 Sublime Text 菜单打开您的用户 AutoPep8.sublime-settings 文件:

Menu --> Preferences --> Package Settings --> AutoPep8 --> Settings – User

我建议您尝试这些 AutoPep8.sublime-settings 设置:

{
    "format_on_save": true,
    "max-line-length": 100,
    // Crucially "ignore" uses a string with comma
    // separated values and not a list of strings.
    "ignore": "E251, W291, E501"
}