Merge pull request #668 from markbaas/master

added import sorting using isort + small yapf fix
This commit is contained in:
Glavin Wiechert 2015-11-25 16:57:25 -04:00
commit ca5529a2dc
7 changed files with 49 additions and 9 deletions

View File

@ -41,6 +41,7 @@ before_install:
# Python language support
- brew install python
- pip install --upgrade autopep8
- pip install --upgrade isort
# SQL language support
- pip install --upgrade sqlparse
# Java, C, C++, C#, Objective-C, D, Pawn, Vala

View File

@ -33,6 +33,7 @@
indent_with_tabs: false
python:
indent_size: 2
sort_imports: true
#max_line_length: 79
#ignore:
# - "E24"
@ -43,4 +44,4 @@
ruby:
indent_size: 4
erb:
indent_size: 4
indent_size: 4

View File

@ -0,0 +1,5 @@
import os
import sys
from pprint import pprint
from scrapy import FormRequest, Request

View File

@ -0,0 +1,4 @@
from scrapy import Request, FormRequest
import sys
import os
from pprint import pprint

View File

@ -15,10 +15,24 @@ module.exports = class Autopep8 extends Beautifier
beautify: (text, language, options) ->
@run("autopep8", [
@tempFile("input", text)
tempFile = @tempFile("input", text)
"-i"
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
["--indent-size","#{options.indent_size}"] if options.indent_size?
["--ignore","#{options.ignore.join(',')}"] if options.ignore?
], help: {
link: "https://github.com/hhatto/autopep8"
})
.then(=>
if options.sort_imports
@run("isort",
[tempFile],
help: {
link: "https://github.com/timothycrosley/isort"
})
.then(=>
@readFile(tempFile)
)
else
@readFile(tempFile)
)

View File

@ -15,11 +15,22 @@ module.exports = class Yapf extends Beautifier
beautify: (text, language, options) ->
@run("yapf", [
"-i"
["--style=pep8"]
@tempFile("input", text)
], {
ignoreReturnCode: true,
help: {
link: "https://github.com/google/yapf"
}
})
tempFile = @tempFile("input", text)
], help: {
link: "https://github.com/google/yapf"
}, ignoreReturnCode: true)
.then(=>
if options.sort_imports
@run("isort",
[tempFile],
help: {
link: "https://github.com/timothycrosley/isort"
})
.then(=>
@readFile(tempFile)
)
else
@readFile(tempFile)
)

View File

@ -41,5 +41,9 @@ module.exports = {
items:
type: 'string'
description: "do not fix these errors/warnings"
sort_imports:
type: 'boolean'
default: false
description: "sort imports (requires isort installed)"
}