Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
b4ba8ef4
Commit
b4ba8ef4
authored
Jun 25, 2015
by
José Padilla
Committed by
José Padilla
Jun 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup isort for code style linting
parent
7351a3f6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
8 deletions
+33
-8
.gitignore
+1
-0
.isort.cfg
+6
-0
.travis.yml
+1
-1
requirements/requirements-codestyle.txt
+3
-0
runtests.py
+18
-3
tox.ini
+4
-4
No files found.
.gitignore
View file @
b4ba8ef4
...
...
@@ -14,3 +14,4 @@ MANIFEST
!.gitignore
!.travis.yml
!.isort.cfg
.isort.cfg
0 → 100644
View file @
b4ba8ef4
[settings]
skip=.tox
atomic=true
multi_line_output=5
known_third_party=pytest,django
known_first_party=rest_framework
.travis.yml
View file @
b4ba8ef4
...
...
@@ -3,7 +3,7 @@ language: python
sudo
:
false
env
:
-
TOX_ENV=py27-
flake8
-
TOX_ENV=py27-
lint
-
TOX_ENV=py27-docs
-
TOX_ENV=py34-django18
-
TOX_ENV=py33-django18
...
...
requirements/requirements-codestyle.txt
View file @
b4ba8ef4
# PEP8 code linting, which we run on all commits.
flake8==2.4.0
pep8==1.5.7
# Sort and lint imports
isort==3.9.6
runtests.py
View file @
b4ba8ef4
#! /usr/bin/env python
from
__future__
import
print_function
import
pytest
import
sys
import
os
import
subprocess
import
sys
import
pytest
PYTEST_ARGS
=
{
'default'
:
[
'tests'
,
'--tb=short'
],
...
...
@@ -14,6 +14,7 @@ PYTEST_ARGS = {
FLAKE8_ARGS
=
[
'rest_framework'
,
'tests'
,
'--ignore=E501'
]
ISORT_ARGS
=
[
'--recursive'
,
'--check-only'
,
'.'
]
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
))
...
...
@@ -30,6 +31,13 @@ def flake8_main(args):
return
ret
def
isort_main
(
args
):
print
(
'Running isort code checking'
)
ret
=
subprocess
.
call
([
'isort'
]
+
args
)
print
(
'isort failed'
if
ret
else
'isort passed'
)
return
ret
def
split_class_and_function
(
string
):
class_string
,
function_string
=
string
.
split
(
'.'
,
1
)
return
"
%
s and
%
s"
%
(
class_string
,
function_string
)
...
...
@@ -50,8 +58,10 @@ if __name__ == "__main__":
sys
.
argv
.
remove
(
'--nolint'
)
except
ValueError
:
run_flake8
=
True
run_isort
=
True
else
:
run_flake8
=
False
run_isort
=
False
try
:
sys
.
argv
.
remove
(
'--lintonly'
)
...
...
@@ -67,6 +77,7 @@ if __name__ == "__main__":
else
:
style
=
'fast'
run_flake8
=
False
run_isort
=
False
if
len
(
sys
.
argv
)
>
1
:
pytest_args
=
sys
.
argv
[
1
:]
...
...
@@ -79,7 +90,7 @@ if __name__ == "__main__":
expression
=
split_class_and_function
(
first_arg
)
pytest_args
=
[
'tests'
,
'-k'
,
expression
]
+
pytest_args
[
1
:]
elif
is_class
(
first_arg
)
or
is_function
(
first_arg
):
# `runtests.py TestCase [flags]`
# `runtests.py TestCase [flags]`
# `runtests.py test_function [flags]`
pytest_args
=
[
'tests'
,
'-k'
,
pytest_args
[
0
]]
+
pytest_args
[
1
:]
else
:
...
...
@@ -87,5 +98,9 @@ if __name__ == "__main__":
if
run_tests
:
exit_on_failure
(
pytest
.
main
(
pytest_args
))
if
run_flake8
:
exit_on_failure
(
flake8_main
(
FLAKE8_ARGS
))
if
run_isort
:
exit_on_failure
(
isort_main
(
ISORT_ARGS
))
tox.ini
View file @
b4ba8ef4
...
...
@@ -3,7 +3,7 @@ addopts=--tb=short
[tox]
envlist
=
py27-{
flake8
,docs},
py27-{
lint
,docs},
{py26,py27}-django14,
{py26,py27,py32,py33,py34}-django{15,16},
{py27,py32,py33,py34}-django{17,18,master}
...
...
@@ -22,14 +22,14 @@ deps =
-rrequirements/requirements-testing.txt
-rrequirements/requirements-optionals.txt
[testenv:py27-flake8]
[testenv:py27-lint]
commands
=
./runtests.py --lintonly
deps
=
-rrequirements/requirements-codestyle.txt
-rrequirements/requirements-testing.txt
commands
=
./runtests.py --lintonly
[testenv:py27-docs]
commands
=
mkdocs build
deps
=
-rrequirements/requirements-testing.txt
-rrequirements/requirements-documentation.txt
commands
=
mkdocs build
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment