src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py

branch
eric7
changeset 10359
de0420dac60e
parent 10356
09c698245a5c
child 10360
9ffdb1490bd2
equal deleted inserted replaced
10358:957c9de01d42 10359:de0420dac60e
2438 itemContext.func.attr == "assertRaises" 2438 itemContext.func.attr == "assertRaises"
2439 or ( 2439 or (
2440 itemContext.func.attr == "raises" 2440 itemContext.func.attr == "raises"
2441 and isinstance(itemContext.func.value, ast.Name) 2441 and isinstance(itemContext.func.value, ast.Name)
2442 and itemContext.func.value.id == "pytest" 2442 and itemContext.func.value.id == "pytest"
2443 and "match" 2443 and "match" not in [kwd.arg for kwd in itemContext.keywords]
2444 not in [kwd.arg for kwd in itemContext.keywords]
2445 ) 2444 )
2446 ) 2445 )
2447 ) 2446 )
2448 or ( 2447 or (
2449 isinstance(itemContext.func, ast.Name) 2448 isinstance(itemContext.func, ast.Name)
2918 Emit a warning if a likely unchanging key is used - either a constant, 2917 Emit a warning if a likely unchanging key is used - either a constant,
2919 or a variable that isn't coming from the generator expression. 2918 or a variable that isn't coming from the generator expression.
2920 """ 2919 """
2921 if isinstance(node.key, ast.Constant): 2920 if isinstance(node.key, ast.Constant):
2922 self.violations.append((node, "M535", node.key.value)) 2921 self.violations.append((node, "M535", node.key.value))
2923 elif isinstance(node.key, ast.Name): 2922 elif isinstance(
2924 if node.key.id not in self.__getDictCompLoopVarNames(node): 2923 node.key, ast.Name
2925 self.violations.append((node, "M535", node.key.id)) 2924 ) and node.key.id not in self.__getDictCompLoopVarNames(node):
2925 self.violations.append((node, "M535", node.key.id))
2926 2926
2927 2927
2928 class NameFinder(ast.NodeVisitor): 2928 class NameFinder(ast.NodeVisitor):
2929 """ 2929 """
2930 Class to extract a name out of a tree of nodes. 2930 Class to extract a name out of a tree of nodes.

eric ide

mercurial