【问题标题】:My VS Code doesn't respect PEP8 line limit on auto formatting我的 VS Code 不遵守自动格式化的 PEP8 行限制
【发布时间】:2019-10-01 14:55:08
【问题描述】:

我已经启用了 autopep8 扩展,当我保存文件时它会在我的 VS Code 底部显示渲染,但它不尊重 PEP8 中的换行,无论它有多大。如何启用自动换行?

这是我的 settings.json:

{
    "files.trimTrailingWhitespace": true,
    "python.formatting.provider": "yapf",
    "editor.formatOnSave": true,

    "[python]": {
        "editor.rulers": [90]
    },
}

代码示例:

translated_msg = self.string_parser.receive_a_string_with_or_without_tokens_and_return_it_with_the_proper_values(final_msg)

对不起,长名字的方法,这不是我的错

至少不应该这样吗?

translated_msg = self.string_parser.receive_a_string_with_or_without_tokens_and_return_it_with_the_proper_values(
    final_msg
)

【问题讨论】:

    标签: python visual-studio-code pep8 autoformatting autoformat


    【解决方案1】:

    两件事。一,您的设置设置为使用yapf,而不是autopep8,但您的问题提到了后者。那么你使用的是yapf 还是autopep8

    第二,您可以通过配置文件或通过"python.formatting.autopep8Args" 的命令行标志来指定行长。请参阅autopep8 docs 了解如何指定行长。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-04
      • 1970-01-01
      • 2020-11-02
      • 2018-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多