diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a36b71b57..2017dacfb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,8 @@ Changelog ========= 0.14.1 ------- -- `ManyToManyField` is now a function instead of a class. +- ``ManyToManyField`` is now a function that has the type of the relation for autocomplete, + this allows for better type hinting at less effort. - Added section on adding better autocomplete for relations in editors. 0.14.0 diff --git a/Makefile b/Makefile index cbda8e9f6..73527456e 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ _testall: $(py_warn) TORTOISE_TEST_DB=sqlite://:memory: py.test --cov-report= python -V | grep PyPy || $(py_warn) TORTOISE_TEST_DB=postgres://postgres:$(TORTOISE_POSTGRES_PASS)@127.0.0.1:5432/test_\{\} py.test --cov-append --cov-report= $(py_warn) TORTOISE_TEST_DB="mysql://root:$(TORTOISE_MYSQL_PASS)@127.0.0.1:3306/test_\{\}?storage_engine=MYISAM" py.test --cov-append --cov-report= - $(py_warn) TORTOISE_TEST_DB="mysql:$(TORTOISE_MYSQL_PASS)//root:@127.0.0.1:3306/test_\{\}" py.test --cov-append + $(py_warn) TORTOISE_TEST_DB="mysql://root:$(TORTOISE_MYSQL_PASS)@127.0.0.1:3306/test_\{\}" py.test --cov-append testall: deps _testall diff --git a/docs/models.rst b/docs/models.rst index f6ab82f49..2a75f5116 100644 --- a/docs/models.rst +++ b/docs/models.rst @@ -306,8 +306,8 @@ Sync usage requires that you call `fetch_related` before the time, and then you The reverse lookup of ``team.event_team`` works exactly the same way. -``Improving relational type hinting`` -------------------------------------- +Improving relational type hinting +================================= Since Tortoise ORM is still a young project, it does not have such widespread support by various editors who help you writing code using good autocomplete for models and diff --git a/docs/sphinx_autodoc_typehints.py b/docs/sphinx_autodoc_typehints.py index c96cab4f6..bb4b4ec24 100644 --- a/docs/sphinx_autodoc_typehints.py +++ b/docs/sphinx_autodoc_typehints.py @@ -212,8 +212,8 @@ def get_all_type_hints(obj, name): pass except NameError as exc: try: - rv = get_type_hints(obj, sys.modules['tortoise'].__dict__) - except: + rv = get_type_hints(obj, localns=sys.modules['tortoise'].__dict__) + except Exception as exc: logger.warning('Cannot resolve forward reference in type annotations of "%s": %s', name, exc) rv = obj.__annotations__ @@ -233,9 +233,12 @@ def get_all_type_hints(obj, name): except (AttributeError, TypeError): pass except NameError as exc: - logger.warning('Cannot resolve forward reference in type annotations of "%s": %s', - name, exc) - rv = obj.__annotations__ + try: + rv = get_type_hints(obj, localns=sys.modules['tortoise'].__dict__) + except: + logger.warning('Cannot resolve forward reference in type annotations of "%s": %s', + name, exc) + rv = obj.__annotations__ return rv diff --git a/tests/requirements-pypy.txt b/tests/requirements-pypy.txt index f91946005..37a4b8c53 100644 --- a/tests/requirements-pypy.txt +++ b/tests/requirements-pypy.txt @@ -11,7 +11,7 @@ asynctest==0.13.0 atomicwrites==1.3.0 # via pytest attrs==19.3.0 # via pytest certifi==2019.9.11 # via requests -cffi==1.13.1 # via cryptography +cffi==1.13.2 # via cryptography chardet==3.0.4 # via requests ciso8601==2.1.2 coverage==4.5.4 # via coveralls, pytest-cov @@ -27,16 +27,16 @@ pluggy==0.13.0 # via pytest py==1.8.0 # via pytest pycparser==2.19 # via cffi pymysql==0.9.2 # via aiomysql -pyparsing==2.4.2 # via packaging -pypika==0.35.14 +pyparsing==2.4.4 # via packaging +pypika==0.35.15 pytest-cov==2.8.1 pytest-forked==1.1.3 # via pytest-xdist pytest-xdist==1.30.0 pytest==5.2.2 pyyaml==5.1.2 requests==2.22.0 # via coveralls -six==1.12.0 # via cryptography, packaging, pytest-xdist -typing-extensions==3.7.4 +six==1.13.0 # via cryptography, packaging, pytest-xdist +typing-extensions==3.7.4.1 urllib3==1.25.6 # via requests wcwidth==0.1.7 # via pytest zipp==0.6.0 # via importlib-metadata diff --git a/tests/requirements.in b/tests/requirements.in index 0ed6aed69..b1e0b8d5e 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -44,7 +44,8 @@ quart;python_version>="3.7" # Sample integration - Sanic sanic +uvloop>=0.12.0; sys_platform != "win32" and implementation_name == "cpython" # Sample integration - Starlette starlette -uvicorn < 0.9 +uvicorn diff --git a/tests/requirements.txt b/tests/requirements.txt index 4a8faaae2..4b709d061 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -11,18 +11,18 @@ aiosqlite==0.10.0 alabaster==0.7.12 # via sphinx apipkg==1.5 # via execnet appdirs==1.4.3 # via black -astroid==2.3.2 # via pylint +astroid==2.3.3 # via pylint asyncpg==0.19.0 asynctest==0.13.0 atomicwrites==1.3.0 # via pytest attrs==19.3.0 # via black, pytest babel==2.7.0 # via sphinx bandit==1.6.2 -black==19.3b0 ; python_version >= "3.6" +black==19.10b0 ; python_version >= "3.6" bleach==3.1.0 # via readme-renderer blinker==1.4 # via quart certifi==2019.9.11 # via httpcore, requests -cffi==1.13.1 # via cryptography +cffi==1.13.2 # via cryptography chardet==3.0.4 # via httpcore, requests ciso8601==2.1.2 click==7.0 # via black, pip-tools, quart, uvicorn @@ -37,7 +37,7 @@ entrypoints==0.3 # via flake8 execnet==1.7.1 # via pytest-xdist filelock==3.0.12 # via tox flake8-isort==2.7.0 -flake8==3.7.8 # via flake8-isort +flake8==3.7.9 # via flake8-isort gitdb2==2.0.6 # via gitpython gitpython==3.0.4 # via bandit green==3.0.0 @@ -54,7 +54,7 @@ importlib-metadata==0.23 # via pluggy, pytest, tox isort==4.3.21 # via flake8-isort, pylint itsdangerous==1.1.0 # via quart jinja2==2.10.3 # via quart, sphinx -lazy-object-proxy==1.4.2 # via astroid +lazy-object-proxy==1.4.3 # via astroid lxml==4.4.1 # via green markupsafe==1.1.1 # via jinja2 mccabe==0.6.1 # via flake8, pylint @@ -64,6 +64,7 @@ mypy-extensions==0.4.3 # via mypy mypy==0.740 nose2==0.9.1 packaging==19.2 # via pytest, sphinx, tox +pathspec==0.6.0 # via black pbr==5.4.3 # via stevedore pip-tools==4.2.0 pkginfo==1.5.0.1 # via twine @@ -76,8 +77,8 @@ pyflakes==2.1.1 # via flake8 pygments==2.4.2 pylint==2.4.3 pymysql==0.9.2 # via aiomysql -pyparsing==2.4.2 # via packaging -pypika==0.35.14 +pyparsing==2.4.4 # via packaging +pypika==0.35.15 pytest-cov==2.8.1 pytest-forked==1.1.3 # via pytest-xdist pytest-xdist==1.30.0 @@ -86,41 +87,42 @@ pytz==2019.3 # via babel pyyaml==5.1.2 quart==0.10.0 ; python_version >= "3.7" readme-renderer==24.0 # via twine +regex==2019.11.1 # via black requests-async==0.5.0 # via sanic requests-toolbelt==0.9.1 # via twine requests==2.22.0 # via coveralls, requests-async, requests-toolbelt, sphinx, twine rfc3986==1.3.2 # via httpcore sanic==19.9.0 -six==1.12.0 # via astroid, bandit, bleach, cryptography, nose2, packaging, pip-tools, pytest-xdist, readme-renderer, sphinx, stevedore, tox +six==1.13.0 # via astroid, bandit, bleach, cryptography, nose2, packaging, pip-tools, pytest-xdist, readme-renderer, sphinx, stevedore, tox smmap2==2.0.5 # via gitdb2 snowballstemmer==2.0.0 # via sphinx sortedcontainers==2.1.0 # via quart sphinx==1.8.5 sphinxcontrib-websupport==1.1.2 # via sphinx -starlette==0.12.10 +starlette==0.12.13 stevedore==1.31.0 # via bandit -testfixtures==6.10.0 # via flake8-isort +testfixtures==6.10.1 # via flake8-isort toml==0.10.0 # via black, hypercorn, tox tox==3.14.0 -tqdm==4.36.1 # via twine +tqdm==4.37.0 # via twine twine==1.15.0 -typed-ast==1.4.0 # via astroid, mypy -typing-extensions==3.7.4 +typed-ast==1.4.0 # via astroid, black, mypy +typing-extensions==3.7.4.1 ujson==1.35 # via sanic unidecode==1.1.1 # via green urllib3==1.25.6 # via requests -uvicorn==0.8.6 -uvloop==0.12.2 # via sanic, uvicorn +uvicorn==0.10.3 +uvloop==0.14.0rc2 ; sys_platform != "win32" and implementation_name == "cpython" virtualenv==16.7.7 # via tox wcwidth==0.1.7 # via pytest webencodings==0.5.1 # via bleach -websockets==7.0 # via sanic, uvicorn +websockets==8.1 # via sanic, uvicorn wrapt==1.11.2 # via astroid wsproto==0.15.0 ; python_version >= "3.7" zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via sphinx, twine +# setuptools==41.6.0 # via sphinx, twine aiocontextvars==0.2.2 ; python_version < "3.7" contextvars==2.4 ; python_version < "3.7" immutables==0.9 ; python_version < "3.7" diff --git a/tortoise/__init__.py b/tortoise/__init__.py index a7c712e65..38bd0c171 100644 --- a/tortoise/__init__.py +++ b/tortoise/__init__.py @@ -655,4 +655,4 @@ async def do_stuff(): loop.run_until_complete(Tortoise.close_connections()) -__version__ = "0.14.0" +__version__ = "0.14.1"