【问题标题】:How can I disable flake8 for a multiline import?如何禁用 flake8 进行多行导入?
【发布时间】:2017-10-17 16:59:17
【问题描述】:

使用 flake8,要禁用某行上的某个错误,请执行以下操作:

example = lambda: 'example'  # noqa: E731,E123

但是,如果我有多行语句,flake8 无法在末尾解析 noqa 语句:

from detect_fixtures import expected_response_stage3_mocked, expected_response_bbox_oob,\
    mock_detection, mock_detection_models, mock_detection_stage1, mock_detection_stage2,\
    mock_detection_stage3_given_bbox, mock_load_image  # noqa: F401   

我想使用 '\' 继续,所以我不想这样做(这确实有效)

from detect_fixtures import (expected_response_stage3_mocked,  # noqa: F401                      
    expected_response_bbox_oob, img, mock_detection, mock_detection_models,  # noqa: F401        
    mock_detection_stage1, mock_detection_stage2, mock_detection_stage3_given_bbox,  # noqa: F401
    mock_load_image)  # noqa: F401          

这里有什么帮助吗?

【问题讨论】:

    标签: python pyflakes


    【解决方案1】:
    from detect_fixtures import (expected_response_stage3_mocked,  # noqa: F401                      
        expected_response_bbox_oob, img, mock_detection, mock_detection_models,  
        mock_detection_stage1, mock_detection_stage2, mock_detection_stage3_given_bbox,
        mock_load_image)
    

    您只需要一个 noqa。 Flake8 将连续线视为一条。

    【讨论】:

      猜你喜欢
      • 2020-04-03
      • 2015-11-15
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 2020-11-03
      相关资源
      最近更新 更多