如何禁用多行导入的flake8?

2024-10-06 08:56:04 发布

您现在位置:Python中文网/ 问答频道 /正文

使用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          

有人帮忙吗


Tags: fromimportflake8exampleresponse语句mockfixtures
1条回答
网友
1楼 · 发布于 2024-10-06 08:56:04
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将连续线视为一条线

相关问题 更多 >