indent_style checks docstring's indent style Args: node (astroid.node): The visiting node. indent (int): The default indent of style Returns: True if successful other wise False.
(self, node, indent=4)
| 190 | |
| 191 | # FIXME(gongwb): give the docstring line-no |
| 192 | def indent_style(self, node, indent=4): |
| 193 | """indent_style checks docstring's indent style |
| 194 | Args: |
| 195 | node (astroid.node): The visiting node. |
| 196 | indent (int): The default indent of style |
| 197 | Returns: |
| 198 | True if successful other wise False. |
| 199 | """ |
| 200 | if node.doc is None: |
| 201 | return True |
| 202 | |
| 203 | doc = node.doc |
| 204 | lines = doc.splitlines() |
| 205 | line_num = 0 |
| 206 | |
| 207 | for l in lines: |
| 208 | if line_num == 0: |
| 209 | continue |
| 210 | cur_indent = len(l) - len(l.lstrip()) |
| 211 | if cur_indent % indent != 0: |
| 212 | self.add_message('W9006', node=node, line=node.fromlineno) |
| 213 | return False |
| 214 | line_num += 1 |
| 215 | |
| 216 | return True |
| 217 | |
| 218 | def one_line(self, node): |
| 219 | """one_line checks if docstring (len < 40) is on one line. |