How do I get Pyflakes to ignore a statement?

前端 未结 7 809
南方客
南方客 2020-11-29 20:33

A lot of our modules start with:

try:
    import json
except ImportError:
    from django.utils import simplejson as json  # Python 2.4 fallback.
         


        
7条回答
  •  一整个雨季
    2020-11-29 21:11

    To quote from the github issue ticket:

    While the fix is still coming, this is how it can be worked around, if you're wondering:

    try:
        from unittest.runner import _WritelnDecorator
        _WritelnDecorator; # workaround for pyflakes issue #13
    except ImportError:
        from unittest import _WritelnDecorator
    

    Substitude _unittest and _WritelnDecorator with the entities (modules, functions, classes) you need

    -- deemoowoor

提交回复
热议问题