Patched the included vulture.py to support the @pyqtSlot() decorator.

Tue, 06 Oct 2015 20:01:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 06 Oct 2015 20:01:23 +0200
changeset 7
a1a6ff3e5486
parent 6
76c0f3ed7ac5
child 8
46783c4f7187

Patched the included vulture.py to support the @pyqtSlot() decorator.

VultureChecker/VultureCheckerDialog.py file | annotate | diff | comparison | revisions
VultureChecker/VultureCheckerService.py file | annotate | diff | comparison | revisions
VultureChecker/vulture.py file | annotate | diff | comparison | revisions
--- a/VultureChecker/VultureCheckerDialog.py	Tue Oct 06 19:29:52 2015 +0200
+++ b/VultureChecker/VultureCheckerDialog.py	Tue Oct 06 20:01:23 2015 +0200
@@ -436,6 +436,7 @@
         """
         self.__definedAttrs = []
         self.__definedFuncs = []
+        self.__definedSlots = []
         self.__definedProps = []
         self.__definedVars = []
         self.__usedAttrs = []
@@ -454,6 +455,8 @@
             [self.__dict2Item(d) for d in result["DefinedAttributes"]]))
         self.__definedFuncs.extend(self.__filteredList(
             [self.__dict2Item(d) for d in result["DefinedFunctions"]]))
+        self.__definedSlots.extend(self.__filteredList(
+            [self.__dict2Item(d) for d in result["DefinedSlots"]]))
         self.__definedProps.extend(self.__filteredList(
             [self.__dict2Item(d) for d in result["DefinedProperties"]]))
         self.__definedVars.extend(self.__filteredList(
--- a/VultureChecker/VultureCheckerService.py	Tue Oct 06 19:29:52 2015 +0200
+++ b/VultureChecker/VultureCheckerService.py	Tue Oct 06 20:01:23 2015 +0200
@@ -203,6 +203,8 @@
                 [self.__item2Dict(i) for i in self.defined_attrs],
             "DefinedFunctions": 
                 [self.__item2Dict(i) for i in self.defined_funcs],
+            "DefinedSlots": 
+                [self.__item2Dict(i) for i in self.defined_slots],
             "DefinedProperties": 
                 [self.__item2Dict(i) for i in self.defined_props],
             "DefinedVariables": 
--- a/VultureChecker/vulture.py	Tue Oct 06 19:29:52 2015 +0200
+++ b/VultureChecker/vulture.py	Tue Oct 06 20:01:23 2015 +0200
@@ -18,7 +18,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+#
+#
 # Patched to support the Python 3.5 async functionality.
+# Patched to support PyQt's @pyqtSlot decorator to consider slots as
+# always used.
+# Patches: Copyright (C) 2015 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 from __future__ import print_function
@@ -63,6 +68,7 @@
 
         self.defined_attrs = []
         self.defined_funcs = []
+        self.defined_slots = []     # @pyqtSlot support
         self.defined_props = []
         self.defined_vars = []
         self.used_attrs = []
@@ -175,6 +181,11 @@
             if getattr(decorator, 'id', None) == 'property':
                 self.defined_props.append(self._get_item(node, 'property'))
                 break
+            elif getattr(decorator, 'func', None) is not None:
+                # @pyqtSlot support
+                if getattr(getattr(decorator, 'func'), 'id') == 'pyqtSlot':
+                    self.defined_slots.append(self._get_item(node, 'slot'))
+                    break
         else:
             # Function is not a property.
             if not _ignore_function(node.name):

eric ide

mercurial