On Fri, Dec 12, 2014 at 2:25 AM, Marius Gedminas <mar...@gedmin.as> wrote:
> flake8 has the doctests option that enables doctest checking.
> Unfortunately it's global.

This is actually a feature of pep8. It's available in flake8 because
it is available in pep8.

> 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?

Frankly, no. The current machinery we have around `# noqa` (and `#
flake8: noqa`) is very simplistic. Pretty much if we see either of
those things, we skip either the line or the file. There's no real, on
or off switch. Having per-file options is an oft-requested feature but
the maintenance and architecture of it is beyond the scope of flake8
as a project.

> 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

Since this is a pep8 flag, you would have to request something like
this for pep8. This may have a better chance of being accepted (and
then once pep8 is released with the feature, you would be able to use
it in flake8 without issue).

> (while keeping support for the boolean values, of course)
>
> Marius Gedminas
> --
> We have enough youth, how about a fountain of SMART?
>
> _______________________________________________
> code-quality mailing list
> code-quality@python.org
> https://mail.python.org/mailman/listinfo/code-quality
>
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality

Reply via email to