Skip to content

Commit 33d2511

Browse files
author
Vladimir Rudnyh
committed
Add new linting tool: flake8-import-order 0.6.1
1 parent f74279c commit 33d2511

File tree

9 files changed

+868
-15
lines changed

9 files changed

+868
-15
lines changed

Flake8Lint.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Check Python files with flake8 (PEP8, pyflake and mccabe)
66
"""
77
from __future__ import print_function
8+
89
import fnmatch
910
import itertools
1011
import os
@@ -44,8 +45,8 @@
4445

4546
PROJECT_SETTINGS_KEYS = (
4647
'python_interpreter', 'builtins', 'pyflakes', 'pep8', 'pydocstyle',
47-
'naming', 'debugger', 'complexity', 'pep8_max_line_length',
48-
'select', 'ignore', 'ignore_files',
48+
'naming', 'debugger', 'import_order', 'import_order_style', 'complexity',
49+
'pep8_max_line_length', 'select', 'ignore', 'ignore_files',
4950
'use_flake8_global_config', 'use_flake8_project_config',
5051
)
5152
FLAKE8_SETTINGS_KEYS = (
@@ -204,6 +205,16 @@ def setup(self):
204205
# turn on flake8-debugger error lint
205206
self.debugger = bool(self.settings.get('debugger', True))
206207

208+
# turn on import order error lint
209+
self.import_order = bool(self.settings.get('import-order', True))
210+
211+
# get import order style
212+
import_order_style = self.settings.get('import-order-style')
213+
if import_order_style in ('cryptography', 'google'):
214+
self.import_order_style = import_order_style
215+
else:
216+
self.import_order_style = 'cryptography'
217+
207218
# turn off complexity check (set number > 0 to check complexity level)
208219
try:
209220
self.complexity = int(self.settings.get('complexity', -1))

Flake8Lint.sublime-settings

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
"naming": true,
7272
// turn on debugger error lint
7373
"debugger": true,
74+
// turn on import order error lint
75+
"import-order": false,
76+
// import order style: "cryptography" or "google"
77+
// See also: https://github.com/public/flake8-import-order#configuration
78+
"import-order-style": "cryptography",
7479
// turn off complexity check (set number > 0 to check complexity level)
7580
"complexity": -1,
7681

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Python Flake8 Lint
22
==================
33

4-
Python Flake8 Lint is a Sublime Text 2/3 plugin for check Python files against some of the style conventions in **[PEP8](http://www.python.org/dev/peps/pep-0008/)**, **[pydocstyle](https://github.com/PyCQA/pydocstyle)**, **[PyFlakes](https://launchpad.net/pyflakes)**, **[mccabe](http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html)** and **[pep8-naming](https://github.com/flintwork/pep8-naming)**.
4+
Python Flake8 Lint is a Sublime Text 2/3 plugin for check Python files against some of the style conventions in **[PEP8](http://www.python.org/dev/peps/pep-0008/)**, **[pydocstyle](https://github.com/PyCQA/pydocstyle)**, **[PyFlakes](https://launchpad.net/pyflakes)**, **[mccabe](http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html)**, **[pep8-naming](https://github.com/flintwork/pep8-naming)**, **[flake8-debugger](https://github.com/JBKahn/flake8-debugger)** and **[flake8-import-order](https://github.com/public/flake8-import-order)**.
55

66
Based on **[bitbucket.org/tarek/flake8](https://bitbucket.org/tarek/flake8)**.
77

@@ -25,6 +25,8 @@ There are additional tools used to lint Python files:
2525

2626
* **[flake8-debugger](https://github.com/JBKahn/flake8-debugger)** is a flake8 debug statement checker.
2727

28+
* **[flake8-import-order](https://github.com/public/flake8-import-order)** is a flake8 plugin that checks import order in the fashion of the Google Python Style Guide (turned off by default).
29+
2830

2931
Install
3032
-------
@@ -127,6 +129,11 @@ Default "Python Flake8 Lint" plugin config: <kbd>Preferences</kbd>-><kbd>Package
127129
"naming": true,
128130
// turn on debugger error lint
129131
"debugger": true,
132+
// turn on import order error lint
133+
"import-order": false,
134+
// import order style: "cryptography" or "google"
135+
// See also: https://github.com/public/flake8-import-order#configuration
136+
"import-order-style": "cryptography",
130137
// turn off complexity check (set number > 0 to check complexity level)
131138
"complexity": -1,
132139

@@ -190,6 +197,8 @@ You could define per-project config for "Python Flake8 Lint". Use <kbd>Project</
190197
"pep8": true,
191198
"pydocstyle": true,
192199
"naming": true,
200+
"import-order": true,
201+
"import-order-style": "google",
193202
"complexity": -1,
194203
"pep8_max_line_length": 79,
195204
"select": [],
@@ -201,8 +210,8 @@ You could define per-project config for "Python Flake8 Lint". Use <kbd>Project</
201210
```
202211

203212

204-
Note
205-
----
213+
Note 1
214+
------
206215

207216
Pep8 ignores "E121", "E123", "E126", "E226", "E24" and "E704" errors by default. This plugin will not ignore them.
208217

@@ -211,8 +220,8 @@ If you're not agree with this plugin, please, add next string in your config:
211220
"ignore": ["E121", "E123", "E126", "E226", "E24", "E704"]
212221

213222

214-
Note
215-
----
223+
Note 2
224+
------
216225

217226
Pydocstyle's errors "D203 1 blank line required before class docstring" and "D211 No blank lines allowed before class docstring" are in conflict with each other. By default error "D203" is disabled. If you want to ignore "D203" error and use old-style class docstring ("D211"), add next string in your config:
218227

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10+
# implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
from __future__ import absolute_import, division, print_function
14+
15+
__all__ = [
16+
"__title__", "__summary__", "__uri__", "__version__", "__author__",
17+
"__email__", "__license__", "__copyright__",
18+
]
19+
20+
__title__ = "flake8-import-order"
21+
__summary__ = (
22+
"Flake8 and pylama plugin that checks the ordering of import statements."
23+
)
24+
__uri__ = "https://github.com/public/flake8-import-order"
25+
26+
__version__ = "0.6.1"
27+
28+
__author__ = "Alex Stapleton"
29+
__email__ = "[email protected]"
30+
31+
__license__ = "LGPLv3"
32+
__copyright__ = "Copyright 2013-2015 %s" % __author__

0 commit comments

Comments
 (0)