summaryrefslogtreecommitdiff
path: root/src/flake8/plugins
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-07-27 08:15:56 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-08-03 16:48:39 -0500
commite14d0e6352efcf78d33c896a425ddc41405acd02 (patch)
tree1993ee784eaf52b1d64bd64fb5c786b7f412f060 /src/flake8/plugins
parent7e806824dfb6934228880585a7caf3c7a81aafc9 (diff)
downloadflake8-e14d0e6352efcf78d33c896a425ddc41405acd02.tar.gz
Serialize Checkers PluginTypeManager to a dict
It seems likely that the multiprocessing module on Windows is not capable of serializing an object with the structure that we have and preserving the attributes we dynamically set on plugins (like the FlakesChecker). To avoid issues like this with all plugins (although we have only found this on Windows with the FlakesChecker), let's try serializing the Checkers PluginTypeManager to a dictionary so that the only object that a Queue is really trying to serialize/deserialize is the FlakesChecker itself. Related to #179
Diffstat (limited to 'src/flake8/plugins')
-rw-r--r--src/flake8/plugins/manager.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/flake8/plugins/manager.py b/src/flake8/plugins/manager.py
index 28f38a6..a5f1c3b 100644
--- a/src/flake8/plugins/manager.py
+++ b/src/flake8/plugins/manager.py
@@ -49,6 +49,16 @@ class Plugin(object):
self.name, self.entry_point
)
+ def to_dictionary(self):
+ """Convert this plugin to a dictionary."""
+ return {
+ 'name': self.name,
+ 'parameters': self.parameters,
+ 'parameter_names': self.parameter_names,
+ 'plugin': self.plugin,
+ 'plugin_name': self.plugin_name,
+ }
+
def is_in_a_group(self):
"""Determine if this plugin is in a group.
@@ -433,6 +443,20 @@ class Checkers(PluginTypeManager):
if argument_name == plugin.parameter_names[0]:
yield plugin
+ def to_dictionary(self):
+ """Return a dictionary of AST and line-based plugins."""
+ return {
+ 'ast_plugins': [
+ plugin.to_dictionary() for plugin in self.ast_plugins
+ ],
+ 'logical_line_plugins': [
+ plugin.to_dictionary() for plugin in self.logical_line_plugins
+ ],
+ 'physical_line_plugins': [
+ plugin.to_dictionary() for plugin in self.physical_line_plugins
+ ],
+ }
+
def register_options(self, optmanager):
"""Register all of the checkers' options to the OptionManager.