How to disable inspections of code inside docstrings?

I recently upgraded to PyCharm 2.7, and I've noticed that PyCharm now has special processing for code examples inside a docstring. For example, if I have a class like the following:

class MyClass(object):
    """Process some data.

    Example usage:
   
    >>> some_function(MyClass())

    """
    pass

As long as I preface code examples with ">>> " or "... ", PyCharm now highlights the code example and performs syntax checks and code inspections. This might be useful in, say, the context of doctests.

Unfortunately, I'm finding that the inspections don't handle this code very well (for example, in the above code, some_function will be considered an "unresolved reference," even if I define it elsewhere in the module), and in general I don't really care about the syntax or coding practices I use in example code.

So is there a way to turn off inspections of code examples in docstrings? I understand why it might be useful for people who use doctests, but I sometimes just put examples in docstrings and don't want them to be inspected.
2
At the moment the docstring analysis cannot be disabled. You're welcome to file a feature request at http://youtrack.jetbrains.com/ to make this optional.
0
Avatar
Permanently deleted user
Thank you. I have added a feature request at PY-8815.
0

In your .idea folder there should be a .iml file with your project name.  Inside there create or add it the component “PyDocumentationSettings” to add a new option “analyzeDoctest” and set it to False.  Mine looks like this.

  <component name="PyDocumentationSettings">
    <option name="format" value="PLAIN" />
    <option name="myDocStringFormat" value="Plain" />
    <option name="analyzeDoctest" value="false" />
  </component>
0

Oh – I forgot how I found this – it is in Settings -> Tools -> Python Integrated Tools -> Analyze Python code in docstrings. 

(Somehow this post is coming up higher on searches than PY-8815, so I'll include this here)

0

请先登录再写评论。