diff options
| author | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-07-28 11:49:58 -0700 |
|---|---|---|
| committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-07-28 11:49:58 -0700 |
| commit | d234f22e09209d586501a9f8cbd03873aedeba62 (patch) | |
| tree | b6e0b226adc7aa653fcfab5b644027d582058159 /src | |
| parent | ebc7ffd4e78e8f010c7ab12f2989fd614ef522d3 (diff) | |
| download | flake8-d234f22e09209d586501a9f8cbd03873aedeba62.tar.gz | |
Raise exception when entry_point not callable
E.g.:
```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
File ".tox/flake8/bin/flake8", line 9, in <module>
load_entry_point('flake8', 'console_scripts', 'flake8')()
File "/Users/marca/dev/git-repos/flake8/src/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 316, in run
self._run(argv)
File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 299, in _run
self.initialize(argv)
File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 289, in initialize
self.find_plugins()
File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 143, in find_plugins
self.check_plugins.load_plugins()
File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 375, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 267, in map
yield func(self.plugins[name], *args, **kwargs)
File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 373, in load_plugin
return plugin.load_plugin()
File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 173, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "P999" due to Plugin <module 'teamcity.flake8_plugin' from '/Users/marca/dev/git-repos/teamcity-messages/teamcity/flake8_plugin.pyc'> is not a callable. It might be written for an older version of flake8 and might not work with this version.
```
This is nicer than the previous behavior of raising an obscure `PicklingError` and then hanging.
```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
send(obj)
PicklingError: Can't pickle <type 'module'>: attribute lookup __builtin__.module failed
```
See #164
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/plugins/manager.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/flake8/plugins/manager.py b/src/flake8/plugins/manager.py index 844a787..28f38a6 100644 --- a/src/flake8/plugins/manager.py +++ b/src/flake8/plugins/manager.py @@ -139,6 +139,12 @@ class Plugin(object): self._plugin = self.entry_point.load( require=verify_requirements ) + if not callable(self._plugin): + msg = ('Plugin %r is not a callable. It might be written for an' + ' older version of flake8 and might not work with this' + ' version' % self._plugin) + LOG.critical(msg) + raise TypeError(msg) def load_plugin(self, verify_requirements=False): """Retrieve the plugin for this entry-point. |
