diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..4d17c9c8 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,6 @@ +[settings] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=100 diff --git a/.travis.yml b/.travis.yml index 9fbf9433..ee58dd62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,10 @@ matrix: sudo: required python: 3.7 env: TOXENV=py37-vulture + - os: linux + sudo: required + python: 3.7 + env: TOXENV=py37-isort - os: linux sudo: required python: pypy3.5-6.0 diff --git a/hug/__init__.py b/hug/__init__.py index 297ba78c..2600bd3f 100644 --- a/hug/__init__.py +++ b/hug/__init__.py @@ -34,7 +34,6 @@ from falcon import * from hug import ( - authentication, directives, exceptions, format, @@ -89,11 +88,11 @@ ) from hug.types import create as type -# The following imports must be imported last for defaults to have access to all modules +# The following imports must be imported last; in particular, defaults to have access to all modules +from hug import authentication # isort:skip from hug import development_runner # isort:skip from hug import defaults # isort:skip - try: # pragma: no cover - defaulting to uvloop if it is installed import uvloop import asyncio diff --git a/requirements/build_common.txt b/requirements/build_common.txt index bd32ae27..567795e0 100644 --- a/requirements/build_common.txt +++ b/requirements/build_common.txt @@ -1,6 +1,5 @@ -r common.txt flake8==3.3.0 -isort==4.2.5 pytest-cov==2.4.0 pytest==4.3.1 python-coveralls==2.9.0 diff --git a/requirements/build_style_tools.txt b/requirements/build_style_tools.txt index a24c2023..063c2e98 100644 --- a/requirements/build_style_tools.txt +++ b/requirements/build_style_tools.txt @@ -1,6 +1,7 @@ -r build_common.txt black==19.3b0 +isort==4.3.20 pep8-naming==0.8.2 flake8-bugbear==19.3.0 vulture==1.0 -bandit==1.6.0 \ No newline at end of file +bandit==1.6.0 diff --git a/tests/test_full_request.py b/tests/test_full_request.py index f7f339a8..56866138 100644 --- a/tests/test_full_request.py +++ b/tests/test_full_request.py @@ -39,11 +39,13 @@ def post(body, response): """ -@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="Can't run hug CLI from travis PyPy") +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Can't run hug CLI from travis PyPy" +) def test_hug_post(tmp_path): - hug_test_file = (tmp_path / "hug_postable.py") + hug_test_file = tmp_path / "hug_postable.py" hug_test_file.write_text(TEST_HUG_API) - hug_server = Popen(['hug', '-f', str(hug_test_file), '-p', '3000']) + hug_server = Popen(["hug", "-f", str(hug_test_file), "-p", "3000"]) time.sleep(5) - requests.post('http://127.0.0.1:3000/test', {'data': 'here'}) + requests.post("http://127.0.0.1:3000/test", {"data": "here"}) hug_server.kill() diff --git a/tox.ini b/tox.ini index 4393037b..502d5c53 100644 --- a/tox.ini +++ b/tox.ini @@ -43,6 +43,14 @@ deps= whitelist_externals=flake8 commands=bandit -r hug/ -ll +[testenv:py37-isort] +deps= + -rrequirements/build_style_tools.txt + marshmallow >=3.0.0rc5 + +whitelist_externals=flake8 +commands=isort -c --diff --recursive hug + [testenv:pywin] deps =-rrequirements/build_windows.txt basepython = {env:PYTHON:}\python.exe