[code-quality] flake8 and per-file doctest checking

Marius Gedminas marius at gedmin.as
Fri Dec 12 09:25:05 CET 2014


flake8 has the doctests option that enables doctest checking.
Unfortunately it's global.

In objgraph I have a file (objgraph.py) where the doctest syntax is used
for examples, and another file (tests.py) where doctests are used for
actual test code.

If I set doctests = yes, I get false positives on objgraph.py about all
the undefined names in my examples.

If I set doctests = no, I get a false positive about 'import gc' in
test.py being unused, despite gc.collect() being called in many doctests.
Also, the code in my doctests doesn't get checked.

Do you think it would make sense to be able to enable/disable doctest
checking per file?  I'm thinking either directives inside the files
themselves, say:

  # flake8: +doctests

or

  # flake8: -doctests

or perhaps a list of glob patterns in setup.cfg, e.g.

  [flake8]
  doctests = tests.py

(while keeping support for the boolean values, of course)

Marius Gedminas
-- 
We have enough youth, how about a fountain of SMART?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 173 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/code-quality/attachments/20141212/82f8f184/attachment.sig>


More information about the code-quality mailing list