1
1
"""Checker of PEP-8 Naming Conventions."""
2
2
import ast
3
- import sys
4
3
from ast import iter_child_nodes
5
4
from collections import deque
6
5
from fnmatch import fnmatchcase
11
10
12
11
__version__ = '0.13.3'
13
12
14
- PYTHON_VERSION = sys .version_info [:3 ]
15
-
16
13
CLASS_METHODS = frozenset ((
17
14
'__new__' ,
18
15
'__init_subclass__' ,
32
29
}
33
30
FUNC_NODES = (ast .FunctionDef , ast .AsyncFunctionDef )
34
31
35
- if PYTHON_VERSION < (3 , 8 ):
36
- def get_arg_name_tuples (node ):
37
- groups = (node .args .args , node .args .kwonlyargs )
38
- return [(arg , arg .arg ) for args in groups for arg in args ]
39
- else :
40
- def get_arg_name_tuples (node ):
41
- groups = (node .args .posonlyargs , node .args .args , node .args .kwonlyargs )
42
- return [(arg , arg .arg ) for args in groups for arg in args ]
32
+
33
+ def get_arg_name_tuples (node ):
34
+ groups = (node .args .posonlyargs , node .args .args , node .args .kwonlyargs )
35
+ return [(arg , arg .arg ) for args in groups for arg in args ]
43
36
44
37
45
38
class _ASTCheckMeta (type ):
@@ -54,12 +47,8 @@ def __init__(cls, class_name, bases, namespace):
54
47
def _err (self , node , code , ** kwargs ):
55
48
lineno , col_offset = node .lineno , node .col_offset
56
49
if isinstance (node , ast .ClassDef ):
57
- if PYTHON_VERSION < (3 , 8 ):
58
- lineno += len (node .decorator_list )
59
50
col_offset += 6
60
51
elif isinstance (node , FUNC_NODES ):
61
- if PYTHON_VERSION < (3 , 8 ):
62
- lineno += len (node .decorator_list )
63
52
col_offset += 4
64
53
code_str = getattr (self , code )
65
54
if kwargs :
0 commit comments