From 88bf76809871bea733d5862f44a2a88237aedb49 Mon Sep 17 00:00:00 2001 From: Mykhailo Havelia Date: Mon, 16 Mar 2020 01:40:35 +0200 Subject: [PATCH] Fix/problems with master (#172) * fix: corrected flake for doc * feat: updated deps * fix: fixed problem connected with running tests * feat: added mypy to ci build * fix: fix mypy --- .travis.yml | 1 - Makefile | 2 +- .../docker-compose.yml | 1 + .../docs/source/pages/commands.rst | 3 ++- .../docs/source/pages/documentation.rst | 2 +- .../docs/source/pages/tests.rst | 1 + .../requirements/development.txt | 14 +++++++------- .../requirements/documentation.txt | 8 ++++---- .../requirements/production.txt | 14 +++++++------- .../{{cookiecutter.project_name}}/app.py | 8 ++++++-- .../utils/check-requirements.py | 7 +++++-- 11 files changed, 35 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2a33022..38085ad4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ before_script: # Disable services enabled by default # http://docs.travis-ci.com/user/database-setup/#MySQL - sudo /etc/init.d/postgresql stop - # - sudo /etc/init.d/mysql stop cache: pip diff --git a/Makefile b/Makefile index 902180ca..e18b185a 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ test: pip install . create-aio-app project_new doc8 project_new/docs/ - cd project_new/ && make lint && docker-compose up test && docker-compose stop + cd project_new/ && make lint && make mypy && docker-compose up test && docker-compose stop ci: flake test diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/docker-compose.yml b/create_aio_app/template/{{cookiecutter.project_name}}/docker-compose.yml index 9e72c7a0..d649c4a1 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/docker-compose.yml +++ b/create_aio_app/template/{{cookiecutter.project_name}}/docker-compose.yml @@ -58,3 +58,4 @@ services: ports: - 8082:8082 entrypoint: py.test -v -p no:warnings + command: '' diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/commands.rst b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/commands.rst index 928b0171..c0f13826 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/commands.rst +++ b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/commands.rst @@ -37,7 +37,8 @@ Testing Database -------- -Next commands are available if you have not disabled ``postgres`` option when creating a project: +Next commands are available if you have not disabled ``postgres`` option when +creating a project: .. csv-table:: diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/documentation.rst b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/documentation.rst index 1bc3e84d..9bc2d2d0 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/documentation.rst +++ b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/documentation.rst @@ -48,4 +48,4 @@ Read more: - style checker for documentation - \ No newline at end of file + diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/tests.rst b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/tests.rst index 280ce766..ad1a2b94 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/tests.rst +++ b/create_aio_app/template/{{cookiecutter.project_name}}/docs/source/pages/tests.rst @@ -24,6 +24,7 @@ If you want to run a single test, you can pass an argument to `docker-compose` like this: .. code-block:: bash + docker-compose run test project_name/main/tests/test_views.py::test_view diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/development.txt b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/development.txt index 156ea25b..9b2426a1 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/development.txt +++ b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/development.txt @@ -1,12 +1,12 @@ -r production.txt -r documentation.txt -mypy==0.670 -flake8==3.7.5 -pytest==5.2.0 -pytest-cov==2.6.1 +mypy==0.770 +flake8==3.7.9 +pytest==5.4.1 +pytest-cov==2.8.1 pytest-aiohttp==0.3.0 -black==18.9b0 +black==19.10b0 -aiohttp-devtools==0.11 -aiohttp-debugtoolbar==0.6.0 \ No newline at end of file +aiohttp-devtools==0.13.1 +aiohttp-debugtoolbar==0.6.0 diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/documentation.txt b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/documentation.txt index 43b7202a..83ddf8dc 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/documentation.txt +++ b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/documentation.txt @@ -1,4 +1,4 @@ -Sphinx==1.8.4 -sphinx-autodoc-typehints==1.6.0 -sphinxcontrib-websupport==1.1.0 -doc8==0.8.0 \ No newline at end of file +Sphinx==2.4.4 +sphinx-autodoc-typehints==1.10.3 +sphinxcontrib-websupport==1.2.0 +doc8==0.8.0 diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/production.txt b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/production.txt index 589eae62..567a0e48 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/requirements/production.txt +++ b/create_aio_app/template/{{cookiecutter.project_name}}/requirements/production.txt @@ -1,15 +1,15 @@ -aiohttp==3.5.4 -aiohttp_jinja2==1.1.0 +aiohttp==3.6.2 +aiohttp_jinja2==1.2.0 trafaret_config==2.0.2 markdown2==2.3.7 {%- if cookiecutter.use_postgres == 'y' %} -aiopg[sa]==0.16.0 -psycopg2-binary==2.7.7 -alembic==1.0.7 +aiopg[sa]==1.0.0 +psycopg2-binary==2.8.4 +alembic==1.4.1 {%- endif %} {%- if cookiecutter.use_redis == 'y' %} -aioredis==1.2.0 +aioredis==1.3.1 {%- endif %} {%- if cookiecutter.use_uvloop == 'y' %} -uvloop==0.12.2 +uvloop==0.14.0 {%- endif %} diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/app.py b/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/app.py index b41472d0..042ec21d 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/app.py +++ b/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/app.py @@ -1,5 +1,9 @@ from pathlib import Path -from typing import Optional, List +from typing import ( + Optional, + List, + AsyncGenerator, +) {%- if cookiecutter.use_redis == 'y' %} from functools import partial @@ -33,7 +37,7 @@ def init_jinja2(app: web.Application) -> None: {%- if cookiecutter.use_postgres == 'y' %} -async def database(app: web.Application) -> None: +async def database(app: web.Application) -> AsyncGenerator[None, None]: ''' A function that, when the server is started, connects to postgresql, and after stopping it breaks the connection (after yield) diff --git a/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/utils/check-requirements.py b/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/utils/check-requirements.py index d7dd48d6..9a1fea0f 100644 --- a/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/utils/check-requirements.py +++ b/create_aio_app/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/utils/check-requirements.py @@ -1,3 +1,4 @@ +from typing import Dict import subprocess # nosec import click import re @@ -24,8 +25,10 @@ def upgrade_requirements() -> None: )\ .decode("utf-8").split("\n") - packages = dict( - package.split('==') for package in fresh_version if package) + packages: Dict[str, str] = dict( + package.split('==') # type: ignore + for package in fresh_version if package + ) with req_file.open('w') as f: new_req = old_req