Skip to content

Commit

Permalink
Merge b1eb441 into 2a4a77f
Browse files Browse the repository at this point in the history
  • Loading branch information
grigi committed Sep 21, 2019
2 parents 2a4a77f + b1eb441 commit 72a366c
Show file tree
Hide file tree
Showing 53 changed files with 457 additions and 537 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
python:
- 3.6
- 3.5
- 3.7
env:
global:
Expand All @@ -20,11 +19,11 @@ matrix:
env: TORTOISE_TEST_DB="mysql://root:@127.0.0.1:3306/test_{}"
install: pip install -r requirements-pypy.txt
script: green
- python: 3.6
- python: 3.7
env: TEST_RUNNER=py.test
install: pip install -r requirements-dev.txt
script: py.test
- python: 3.6
- python: 3.7
env: TEST_RUNNER=nose2
install: pip install -r requirements-dev.txt
script: "nose2 --plugin tortoise.contrib.test.nose2 --db-module tortoise.tests.testmodels --db-url sqlite://:memory:"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
checkfiles = tortoise/ examples/ setup.py conftest.py
black_opts = -l 100
black_opts = -l 100 -t py36
py_warn = PYTHONWARNINGS=default PYTHONASYNCIODEBUG=1 PYTHONDEBUG=x PYTHONDEVMODE=dev

help:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You can find docs at `ReadTheDocs <http://tortoise-orm.readthedocs.io/en/latest/
Tortoise ORM is young project and breaking changes are to be expected.
We keep a `Changelog <http://tortoise-orm.readthedocs.io/en/latest/CHANGELOG.html>`_ and it will have possible breakage clearly documented.

Tortoise ORM is supported on CPython >= 3.5.3 for SQLite, MySQL and PostgreSQL, and PyPy3.6 >= 7.1 for SQLite and MySQL only.
Tortoise ORM is supported on CPython >= 3.6 for SQLite, MySQL and PostgreSQL, and PyPy3.6 >= 7.1 for SQLite and MySQL only.

Why was Tortoise ORM built?
---------------------------
Expand Down
7 changes: 3 additions & 4 deletions docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ As this is a value that is different for different people, we have settled on:
* Model/QuerySet usage should be explicit and concise.
* Keep it simple, as simple code not only often runs faster, but has less bugs too.
* Correctness > Ease-Of-Use > Performance > Maintenance
* Test everything. (Currently our test suite is not yet mature)
* Test everything.
* Only do performance/memory optimisation when you have a repeatable benchmark to measure with.


Expand All @@ -97,9 +97,8 @@ Tortoise ORM follows a the following agreed upon style:
* Always try to separate out terms clearly rather than concatenate words directly:
* ``some_purpose`` instead of ``somepurpose``
* ``SomePurpose`` instead of ``Somepurpose``
* Keep in mind the targeted Python versions of ``>=3.5.3``:
* Don't use f-strings
* Stick to comment-style variable type annotations
* Keep in mind the targeted Python versions of ``>=3.6``:
* Do use f-strings
* Please try and provide type annotations where you can, it will improve auto-completion in editors, and better static analysis.


Binary file modified docs/ORM_Perf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It's engraved in it's design that you are working not with just tables, you work

Source & issue trackers are available at `<https://github.com/tortoise/tortoise-orm/>`_

Tortoise ORM is supported on CPython >= 3.5.3 for SQLite, MySQL and PostgreSQL, and PyPy3.5 >= 5.10 for SQLite and MySQL only.
Tortoise ORM is supported on CPython >= 3.6 for SQLite, MySQL and PostgreSQL, and PyPy3.6 >= 7.1 for SQLite and MySQL only.

Introduction
============
Expand Down
2 changes: 1 addition & 1 deletion examples/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def run():
await event.save()
participants = []
for i in range(2):
team = Team(name="Team {}".format(i + 1))
team = Team(name=f"Team {(i + 1)}")
await team.save()
participants.append(team)
await event.participants.add(participants[0], participants[1])
Expand Down
4 changes: 2 additions & 2 deletions examples/quart/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Users(Model):
status = fields.CharField(20)

def __str__(self):
return "User {}: {}".format(self.id, self.status)
return f"User {self.id}: {self.status}"


class Workers(Model):
id = fields.IntField(pk=True)
status = fields.CharField(20)

def __str__(self):
return "Worker {}: {}".format(self.id, self.status)
return f"Worker {self.id}: {self.status}"
2 changes: 1 addition & 1 deletion examples/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def run():
await event.save()
participants = []
for i in range(2):
team = Team(name="Team {}".format(i + 1))
team = Team(name=f"Team {(i + 1)}")
await team.save()
participants.append(team)
await event.participants.add(participants[0], participants[1])
Expand Down
40 changes: 20 additions & 20 deletions examples/relations_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ class Employee(Model):
def __str__(self):
return self.name

# async def full_hierarchy__async_for(self, level=0):
# """
# Demonstrates ``async for` to fetch relations
#
# An async iterator will fetch the relationship on-demand.
# """
# text = [
# "{}{} (to: {}) (from: {})".format(
# level * " ",
# self,
# ", ".join([str(val) async for val in self.talks_to]),
# ", ".join([str(val) async for val in self.gets_talked_to]),
# )
# ]
# async for member in self.team_members:
# text.append(await member.full_hierarchy__async_for(level + 1))
# return "\n".join(text)
async def full_hierarchy__async_for(self, level=0):
"""
Demonstrates ``async for` to fetch relations
An async iterator will fetch the relationship on-demand.
"""
text = [
"{}{} (to: {}) (from: {})".format(
level * " ",
self,
", ".join([str(val) async for val in self.talks_to]),
", ".join([str(val) async for val in self.gets_talked_to]),
)
]
async for member in self.team_members:
text.append(await member.full_hierarchy__async_for(level + 1))
return "\n".join(text)

async def full_hierarchy__fetch_related(self, level=0):
"""
Demonstrates ``await .fetch_related`` to fetch relations
On prefetching the data, the relationship files will contain a regular list.
This is how one would get relations working on sync serialisation/templating frameworks.
This is how one would get relations working on sync serialization/templating frameworks.
"""
await self.fetch_related("team_members", "talks_to", "gets_talked_to")
text = [
Expand Down Expand Up @@ -78,14 +78,14 @@ async def run():

# Evaluated off creation objects
print(await loose.full_hierarchy__fetch_related())
# print(await root.full_hierarchy__async_for())
print(await root.full_hierarchy__async_for())
print(await root.full_hierarchy__fetch_related())

# Evaluated off new objects → Result is identical
root2 = await Employee.get(name="Root")
loose2 = await Employee.get(name="Loose")
print(await loose2.full_hierarchy__fetch_related())
# print(await root2.full_hierarchy__async_for())
print(await root2.full_hierarchy__async_for())
print(await root2.full_hierarchy__fetch_related())


Expand Down
2 changes: 1 addition & 1 deletion examples/sanic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class Users(Model):
name = fields.CharField(50)

def __str__(self):
return "User {}: {}".format(self.id, self.name)
return f"User {self.id}: {self.name}"
2 changes: 1 addition & 1 deletion examples/starlette/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class Users(models.Model):
username = fields.CharField(max_length=20)

def __str__(self) -> str:
return "User {}: {}".format(self.id, self.username)
return f"User {self.id}: {self.username}"
7 changes: 2 additions & 5 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ hypercorn;python_version>="3.7"
quart;python_version>="3.7"

# Sample integration - Sanic
httpcore;python_version>="3.6"
sanic;python_version>="3.6"
requests-async;python_version>="3.6"
sanic

# Sample integration - Starlette
uvicorn==0.8.6; python_version>="3.6"
starlette;python_version>="3.6"
starlette
25 changes: 12 additions & 13 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ certifi==2019.6.16 # via httpcore, requests
cffi==1.12.3 # via cryptography
chardet==3.0.4 # via httpcore, requests
ciso8601==2.1.1
click==7.0 # via black, pip-tools, quart, uvicorn
click==7.0 # via black, pip-tools, quart
cloud-sptheme==1.9.4
colorama==0.4.1 # via green
coverage==4.5.4 # via coveralls, green, nose2
Expand All @@ -40,16 +40,16 @@ flake8==3.7.8 # via flake8-isort
gitdb2==2.0.5 # via gitpython
gitpython==3.0.2 # via bandit
green==3.0.0
h11==0.8.1 # via httpcore, hypercorn, uvicorn, wsproto
h11==0.8.1 # via httpcore, hypercorn, wsproto
h2==3.1.1 # via httpcore, hypercorn
hpack==3.0.0 # via h2
httpcore==0.3.0 ; python_version >= "3.6"
httptools==0.0.13 # via sanic, uvicorn
httpcore==0.3.0 # via requests-async
httptools==0.0.13 # via sanic
hypercorn==0.8.2 ; python_version >= "3.7"
hyperframe==5.2.0 # via h2
idna==2.8 # via httpcore, requests
imagesize==1.1.0 # via sphinx
importlib-metadata==0.20 # via pluggy, pytest, tox
importlib-metadata==0.21 # via pluggy, pytest, tox
isort==4.3.21 # via flake8-isort, pylint
itsdangerous==1.1.0 # via quart
jinja2==2.10.1 # via quart, sphinx
Expand All @@ -66,7 +66,7 @@ packaging==19.1 # via pytest, sphinx, tox
pbr==5.4.3 # via stevedore
pip-tools==4.1.0
pkginfo==1.5.0.1 # via twine
pluggy==0.12.0 # via pytest, tox
pluggy==0.13.0 # via pytest, tox
priority==1.3.0 # via hypercorn
py==1.8.0 # via pytest, tox
pycodestyle==2.5.0 # via flake8
Expand All @@ -82,36 +82,35 @@ pytz==2019.2 # via babel
pyyaml==5.1.2
quart==0.10.0 ; python_version >= "3.7"
readme-renderer==24.0 # via twine
requests-async==0.5.0 ; python_version >= "3.6"
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.6.3 ; python_version >= "3.6"
sanic==19.6.3
six==1.12.0 # via astroid, bandit, bleach, cryptography, nose2, packaging, pip-tools, readme-renderer, sphinx, stevedore, tox
smmap2==2.0.5 # via gitdb2
snowballstemmer==1.9.1 # via sphinx
sortedcontainers==2.1.0 # via quart
sphinx-autodoc-typehints==1.6.0
sphinx==1.8.5
sphinxcontrib-websupport==1.1.2 # via sphinx
starlette==0.12.9 ; python_version >= "3.6"
starlette==0.12.9
stevedore==1.31.0 # via bandit
testfixtures==6.10.0 # via flake8-isort
toml==0.10.0 # via black, hypercorn, tox
tox==3.14.0
tqdm==4.35.0 # via twine
twine==1.13.0
twine==1.14.0
typed-ast==1.4.0 # via astroid, mypy
typing-extensions==3.7.4 # via hypercorn, mypy
ujson==1.35 # via sanic
unidecode==1.1.1 # via green
urllib3==1.25.3 # via requests
uvicorn==0.8.6 ; python_version >= "3.6"
uvloop==0.12.2 # via sanic, uvicorn
uvloop==0.13.0 # via sanic
virtualenv==16.7.5 # via tox
wcwidth==0.1.7 # via pytest
webencodings==0.5.1 # via bleach
websockets==7.0 # via sanic, uvicorn
websockets==7.0 # via sanic
wrapt==1.11.2 # via astroid
wsproto==0.15.0 ; python_version >= "3.7"
zipp==0.6.0 # via importlib-metadata
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ warn_unused_ignores = True
warn_no_return = True
warn_return_any = False
warn_unused_configs = True
warn_unreachable = True
allow_redefinition = True
strict_equality = True
show_error_context = True
Expand All @@ -40,6 +41,7 @@ show_error_context = True
check_untyped_defs = False
disallow_untyped_defs = False
disallow_incomplete_defs = False
warn_unreachable = False

[mypy-examples.*]
check_untyped_defs = False
Expand Down
7 changes: 1 addition & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# coding: utf8
import re
import sys
import warnings

from setuptools import find_packages, setup

if sys.version_info < (3, 5, 3):
raise RuntimeError("tortoise requires Python 3.5.3+")

if sys.version_info < (3, 6):
warnings.warn("Tortoise-ORM is soon going to require Python 3.6", DeprecationWarning)
raise RuntimeError("Tortoise-ORM requires Python >= 3.6")


def version() -> str:
Expand Down Expand Up @@ -51,7 +47,6 @@ def requirements() -> list:
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
Expand Down
Loading

0 comments on commit 72a366c

Please sign in to comment.