MiscellaneousChecker: changed code to cope with some strange situation where the arguments of a function definition don't have the kw_defaults attribute (AST).

Tue, 09 Jul 2019 19:08:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 09 Jul 2019 19:08:24 +0200
changeset 7057
0e8d3b0c4889
parent 7056
516361cdd2d2
child 7060
d04e8965af91

MiscellaneousChecker: changed code to cope with some strange situation where the arguments of a function definition don't have the kw_defaults attribute (AST).

eric6/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Tue Jul 09 19:07:03 2019 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Tue Jul 09 19:08:24 2019 +0200
@@ -760,7 +760,12 @@
         for node in ast.walk(self.__tree):
             if any(isinstance(node, functionDef)
                    for functionDef in functionDefs):
-                for default in node.args.defaults + node.args.kw_defaults:
+                defaults = node.args.defaults[:]
+                try:
+                    defaults += node.args.kw_defaults[:]
+                except AttributeError:
+                    pass
+                for default in defaults:
                     if any(isinstance(default, mutableType)
                            for mutableType in mutableTypes):
                         typeName = type(default).__name__

eric ide

mercurial