PEP8 checking doctest



I can not work out how to format my doctests so that the code inspector considers them to be correct (or alternatively to disable checking of doctests).

Here is an example:

def update(self):
"""Context manager to ensure that all observers are correctly
notified of changes to the model.


>>> m = BaseTableModel(None, [], [])
>>> with m.update():
... m.mylist.append([])

The results from the code inspector are:

PEP 8: unexpected indentation
PEP 8: expected an indented block

Can you tell me how I should format this code so that the inspector thinks that it is valid, or how to turn off code inspection for doctests?

Many thanks



Comment actions Permalink

Hi Richard,


What do you mean by "Code inspector"? In my case there are no PEP-8-related errors for this code in the editor and "Inspect Code" doesn't report anything either. Normally, "PEP 8 coding style violations" inspection should be disabled for any sort of injected Python fragment. Could you please clarify where exactly you see these results?

Comment actions Permalink

Hi Mikhail

What I meant by 'Code Inspector' is the functionality that dynamically shows warning and errors in the editor by highlighting the offending code.

I was seeing these warnings in the editor window. However, with the latest version (2016.3.2) they no longer appear.

So I guess the issue has been resolved.

All the best.




Please sign in to leave a comment.