pgjones / flake8-sql

Flake8 plugin that checks SQL code against opinionated style rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to run flake8_sql with flake8 on Ubuntu 14.04

unicast opened this issue · comments

pip install flake8_sql
Collecting flake8_sql
/usr/local/lib/python2.7/dist-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading flake8_SQL-0.2.0-py2.py3-none-any.whl
Collecting sqlparse (from flake8_sql)
Downloading sqlparse-0.2.3-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/dist-packages (from flake8_sql)
Collecting flake8 (from flake8_sql)
Downloading flake8-3.3.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 3.2MB/s
Collecting pyflakes<1.6.0,>=1.5.0 (from flake8->flake8_sql)
Downloading pyflakes-1.5.0-py2.py3-none-any.whl (225kB)
100% |████████████████████████████████| 225kB 3.3MB/s
Requirement already satisfied (use --upgrade to upgrade): enum34; python_version < "3.4" in /usr/local/lib/python2.7/dist-packages (from flake8->flake8_sql)
Requirement already satisfied (use --upgrade to upgrade): configparser; python_version < "3.2" in /usr/local/lib/python2.7/dist-packages (from flake8->flake8_sql)
Collecting mccabe<0.7.0,>=0.6.0 (from flake8->flake8_sql)
Downloading mccabe-0.6.1-py2.py3-none-any.whl
Collecting pycodestyle<2.4.0,>=2.0.0 (from flake8->flake8_sql)
Downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kB)
100% |████████████████████████████████| 51kB 5.1MB/s
Installing collected packages: sqlparse, pyflakes, mccabe, pycodestyle, flake8, flake8-sql
Successfully installed flake8-3.3.0 flake8-sql-0.2.0 mccabe-0.6.1 pycodestyle-2.3.1 pyflakes-1.5.0 sqlparse-0.2.3
/usr/local/lib/python2.7/dist-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ flake8 --help
Traceback (most recent call last):
File "/usr/local/bin/flake8", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 328, in run
self._run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 315, in _run
self.initialize(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 297, in initialize
self.find_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 147, in find_plugins
self.check_plugins.load_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 392, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 284, in map
yield func(self.plugins[name], *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 390, in load_plugin
return plugin.load_plugin()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 183, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "Q4" due to invalid syntax (linter.py, line 25).

This extension only works with Python 3, you can create a Python3 virtual env, install this plugin and run it over your code though.

@pgjones thank you! Does it requires specific version of Python? No luck with Python 3.4 as well:
~$ flake8
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 175, in load_plugin
self._load(verify_requirements)
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 147, in _load
self._plugin = resolve()
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 2297, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.4/dist-packages/flake8_sql/init.py", line 1, in
from .linter import Linter
File "/usr/local/lib/python3.4/dist-packages/flake8_sql/linter.py", line 3, in
from typing import Any, Generator, Iterable, List, Optional, Tuple, TypeVar
ImportError: No module named 'typing'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/flake8", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.4/dist-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/usr/local/lib/python3.4/dist-packages/flake8/main/application.py", line 328, in run
self._run(argv)
File "/usr/local/lib/python3.4/dist-packages/flake8/main/application.py", line 315, in _run
self.initialize(argv)
File "/usr/local/lib/python3.4/dist-packages/flake8/main/application.py", line 297, in initialize
self.find_plugins()
File "/usr/local/lib/python3.4/dist-packages/flake8/main/application.py", line 147, in find_plugins
self.check_plugins.load_plugins()
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 392, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 284, in map
yield func(self.plugins[name], *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 390, in load_plugin
return plugin.load_plugin()
File "/usr/local/lib/python3.4/dist-packages/flake8/plugins/manager.py", line 183, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "Q4" due to No module named 'typing'

Ah, yea typing was added in Python 3.5. I'll update the setup.py file to take care of this. A quick fix for you is either to pip install typing (there is a backport) or switch to 3.5 or 3.6.

Installing typing helped, thank you!