如何在多行代码中忽略flake8?

时间:2017-10-17 16:59:18

标签: python pyflakes

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

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   

但是,如果我有 多行语句,则flake8无法 来解析最后的noqa语句:

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          

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

_ivars

这里有任何帮助吗?

1 个答案:

答案 0 :(得分:3)

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将连续线视为单个连续线。