How do I disable “TODO” warnings in pylint?

后端 未结 3 607
一生所求
一生所求 2021-02-18 20:50

When running pylint on a python file it shows me warnings regarding TODO comments by default. E.g.:

************* Module foo
W:200, 0: TODO(SE): fi

相关标签:
3条回答
  • 2021-02-18 21:12

    Along with the solution posted by @sthenault where you could disable all warnings, Pylint also allows you to ignore a single line (helpful if you would want to deal with it in the future) like so:

    A_CONSTANT = 'ugh.'  # TODO: update value  # pylint: disable=fixme
    

    or by stating the Rule ID:

    A_CONSTANT = 'ugh.'  # TODO: update value  # pylint: disable=W0511
    
    0 讨论(0)
  • 2021-02-18 21:22

    In our projects we have a pylint.cfg file. We use the --rcfile pylint option to point to that file.

    In pylint.cfg, I can disable checker W0511, which is the checker that complains about "TODO" and similar terms in comments. Just add W0511 to the comma-separated list for parameter disable.

    But remember that, as Uncle Bob Martin says, a TODO is not an excuse to leave bad code in the system, and the code should be scanned regularly to remove TODOs, and pylint and/or sonarqube issues can work as good reminders and motivation for doing so.

    0 讨论(0)
  • 2021-02-18 21:26

    in the generated config file, you should see a section

      [MISCELLANEOUS]
    
      # List of note tags to take in consideration, separated by a comma.
      notes=FIXME,XXX,TODO
    

    simply drop TODO from the "notes" list.

    The config file is found at

    ~/.pylintrc
    

    If you have not generated the config file, this can be done with

    pylint --generate-rcfile > ~/.pylintrc
    
    0 讨论(0)
提交回复
热议问题