11import astroid
22from pylint .interfaces import IAstroidChecker
3+
34from ..utils import _can_use_fixture , _is_class_autouse_fixture
45from . import BasePytestChecker
56
67
78class ClassAttrLoader (BasePytestChecker ):
89 __implements__ = IAstroidChecker
9- msgs = {' E6400' : ('' , ' pytest-class-attr-loader' , '' )}
10+ msgs = {" E6400" : ("" , " pytest-class-attr-loader" , "" )}
1011
1112 in_setup = False
1213 request_cls = set ()
1314 class_node = None
1415
1516 def visit_functiondef (self , node ):
16- ''' determine if a method is a class setup method'''
17+ """ determine if a method is a class setup method"""
1718 self .in_setup = False
1819 self .request_cls = set ()
1920 self .class_node = None
@@ -23,17 +24,23 @@ def visit_functiondef(self, node):
2324 self .class_node = node .parent
2425
2526 def visit_assign (self , node ):
26- '''store the aliases for `cls`'''
27- if self .in_setup and isinstance (node .value , astroid .Attribute ) and \
28- node .value .attrname == 'cls' and \
29- node .value .expr .name == 'request' :
27+ """store the aliases for `cls`"""
28+ if (
29+ self .in_setup
30+ and isinstance (node .value , astroid .Attribute )
31+ and node .value .attrname == "cls"
32+ and node .value .expr .name == "request"
33+ ):
3034 # storing the aliases for cls from request.cls
3135 self .request_cls = set (map (lambda t : t .name , node .targets ))
3236
3337 def visit_assignattr (self , node ):
34- if self .in_setup and isinstance (node .expr , astroid .Name ) and \
35- node .expr .name in self .request_cls and \
36- node .attrname not in self .class_node .locals :
38+ if (
39+ self .in_setup
40+ and isinstance (node .expr , astroid .Name )
41+ and node .expr .name in self .request_cls
42+ and node .attrname not in self .class_node .locals
43+ ):
3744 try :
3845 # find Assign node which contains the source "value"
3946 assign_node = node
0 commit comments