Skip to content

Commit

Permalink
Add new linting tool: flake8-import-order 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Rudnyh committed Feb 2, 2016
1 parent f74279c commit 33d2511
Show file tree
Hide file tree
Showing 9 changed files with 868 additions and 15 deletions.
15 changes: 13 additions & 2 deletions Flake8Lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Check Python files with flake8 (PEP8, pyflake and mccabe)
"""
from __future__ import print_function

import fnmatch
import itertools
import os
Expand Down Expand Up @@ -44,8 +45,8 @@

PROJECT_SETTINGS_KEYS = (
'python_interpreter', 'builtins', 'pyflakes', 'pep8', 'pydocstyle',
'naming', 'debugger', 'complexity', 'pep8_max_line_length',
'select', 'ignore', 'ignore_files',
'naming', 'debugger', 'import_order', 'import_order_style', 'complexity',
'pep8_max_line_length', 'select', 'ignore', 'ignore_files',
'use_flake8_global_config', 'use_flake8_project_config',
)
FLAKE8_SETTINGS_KEYS = (
Expand Down Expand Up @@ -204,6 +205,16 @@ def setup(self):
# turn on flake8-debugger error lint
self.debugger = bool(self.settings.get('debugger', True))

# turn on import order error lint
self.import_order = bool(self.settings.get('import-order', True))

# get import order style
import_order_style = self.settings.get('import-order-style')
if import_order_style in ('cryptography', 'google'):
self.import_order_style = import_order_style
else:
self.import_order_style = 'cryptography'

# turn off complexity check (set number > 0 to check complexity level)
try:
self.complexity = int(self.settings.get('complexity', -1))
Expand Down
5 changes: 5 additions & 0 deletions Flake8Lint.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"naming": true,
// turn on debugger error lint
"debugger": true,
// turn on import order error lint
"import-order": false,
// import order style: "cryptography" or "google"
// See also: https://github.com/public/flake8-import-order#configuration
"import-order-style": "cryptography",
// turn off complexity check (set number > 0 to check complexity level)
"complexity": -1,

Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Python Flake8 Lint
==================

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)**.
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)**.

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

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

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

* **[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).


Install
-------
Expand Down Expand Up @@ -127,6 +129,11 @@ Default "Python Flake8 Lint" plugin config: <kbd>Preferences</kbd>-><kbd>Package
"naming": true,
// turn on debugger error lint
"debugger": true,
// turn on import order error lint
"import-order": false,
// import order style: "cryptography" or "google"
// See also: https://github.com/public/flake8-import-order#configuration
"import-order-style": "cryptography",
// turn off complexity check (set number > 0 to check complexity level)
"complexity": -1,

Expand Down Expand Up @@ -190,6 +197,8 @@ You could define per-project config for "Python Flake8 Lint". Use <kbd>Project</
"pep8": true,
"pydocstyle": true,
"naming": true,
"import-order": true,
"import-order-style": "google",
"complexity": -1,
"pep8_max_line_length": 79,
"select": [],
Expand All @@ -201,8 +210,8 @@ You could define per-project config for "Python Flake8 Lint". Use <kbd>Project</
```


Note
----
Note 1
------

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

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


Note
----
Note 2
------

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:

Expand Down
32 changes: 32 additions & 0 deletions contrib/flake8_import_order/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function

__all__ = [
"__title__", "__summary__", "__uri__", "__version__", "__author__",
"__email__", "__license__", "__copyright__",
]

__title__ = "flake8-import-order"
__summary__ = (
"Flake8 and pylama plugin that checks the ordering of import statements."
)
__uri__ = "https://github.com/public/flake8-import-order"

__version__ = "0.6.1"

__author__ = "Alex Stapleton"
__email__ = "[email protected]"

__license__ = "LGPLv3"
__copyright__ = "Copyright 2013-2015 %s" % __author__
Loading

0 comments on commit 33d2511

Please sign in to comment.