Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py

changeset 4465
2fbb5bdb8ddf
parent 4021
195a471c327b
child 4505
3b437ae320bd
equal deleted inserted replaced
4463:87cd9719dc23 4465:2fbb5bdb8ddf
19 # Python 3 19 # Python 3
20 from io import StringIO # __IGNORE_WARNING__ 20 from io import StringIO # __IGNORE_WARNING__
21 import tokenize 21 import tokenize
22 import ast 22 import ast
23 import sys 23 import sys
24
25 try:
26 ast.AsyncFunctionDef # __IGNORE_EXCEPTION__
27 except AttributeError:
28 ast.AsyncFunctionDef = ast.FunctionDef
24 29
25 30
26 class DocStyleContext(object): 31 class DocStyleContext(object):
27 """ 32 """
28 Class implementing the source context. 33 Class implementing the source context.
1069 try: 1074 try:
1070 tree = ast.parse(context.ssource()) 1075 tree = ast.parse(context.ssource())
1071 except (SyntaxError, TypeError): 1076 except (SyntaxError, TypeError):
1072 return 1077 return
1073 if (isinstance(tree, ast.Module) and len(tree.body) == 1 and 1078 if (isinstance(tree, ast.Module) and len(tree.body) == 1 and
1074 isinstance(tree.body[0], ast.FunctionDef)): 1079 isinstance(tree.body[0],
1080 (ast.FunctionDef, ast.AsyncFunctionDef))):
1075 functionDef = tree.body[0] 1081 functionDef = tree.body[0]
1076 argNames, kwNames = self.__getArgNames(functionDef) 1082 argNames, kwNames = self.__getArgNames(functionDef)
1077 if "self" in argNames: 1083 if "self" in argNames:
1078 argNames.remove("self") 1084 argNames.remove("self")
1079 if "cls" in argNames: 1085 if "cls" in argNames:

eric ide

mercurial