diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-02-04 12:03:07 -0500 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-02-04 12:03:07 -0500 |
commit | 27f7f96728ad5508b40faee986a2ac5d27a84b92 (patch) | |
tree | 98697d9a7c99a5d0db80df08cff236883fea7baa /astroid/rebuilder.py | |
parent | e7c589ca24a47ff130f414cce0939e8f16dd8ab0 (diff) | |
download | astroid-git-27f7f96728ad5508b40faee986a2ac5d27a84b92.tar.gz |
Switch the order of the docstring checks to have the .docstring extractor first
Diffstat (limited to 'astroid/rebuilder.py')
-rw-r--r-- | astroid/rebuilder.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py index d1c9bfed..41ef5b5d 100644 --- a/astroid/rebuilder.py +++ b/astroid/rebuilder.py @@ -81,15 +81,15 @@ CONTEXTS = {_ast.Load: astroid.Load, def _get_doc(node): try: - if (node.body - and isinstance(node.body[0], _ast.Expr) - and isinstance(node.body[0].value, _ast.Str)): + if PY37 and hasattr(node, 'docstring'): + doc = node.docstring + return node, doc + elif (node.body + and isinstance(node.body[0], _ast.Expr) + and isinstance(node.body[0].value, _ast.Str)): doc = node.body[0].value.s node.body = node.body[1:] return node, doc - elif PY37 and hasattr(node, 'docstring'): - doc = node.docstring - return node, doc except IndexError: pass # ast built from scratch return node, None |