Bump supported fastapi versions (#1110)

* Bump supported fastapi version to <=0.97, change all fastapi tests from starlette client to httpx.AsyncClient

* Add lifecycle manager to fastapi tests

* Fix coverage

* Add python 3.11 to test suite, bump version
This commit is contained in:
collerek
2023-06-18 18:52:06 +02:00
committed by GitHub
parent e72e40dd6c
commit b1ab0de4d4
27 changed files with 733 additions and 587 deletions

View File

@ -18,7 +18,6 @@ from typing import (
Union,
cast,
)
import functools
import databases
import pydantic
@ -242,6 +241,7 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass
:param new_hash: The hash to update to
:type new_hash: int
"""
def _update_cache(relations: List[Relation], recurse: bool = True) -> None:
for relation in relations:
relation_proxy = relation.get()
@ -249,7 +249,10 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass
if hasattr(relation_proxy, "update_cache"):
relation_proxy.update_cache(prev_hash, new_hash) # type: ignore
elif recurse and hasattr(relation_proxy, "_orm"):
_update_cache(relation_proxy._orm._relations.values(), recurse=False) # type: ignore
_update_cache(
relation_proxy._orm._relations.values(), # type: ignore
recurse=False,
)
_update_cache(list(self._orm._relations.values()))

View File

@ -133,8 +133,8 @@ class Relation(Generic[T]):
return None
else:
# We need to clear the weakrefs that don't point to anything anymore
# There's an assumption here that if some of the related models went out of scope,
# then they all did, so we can just check the first one
# There's an assumption here that if some of the related models
# went out of scope, then they all did, so we can just check the first one
try:
self.related_models[0].__repr__.__self__
return self.related_models.index(child)

View File

@ -145,7 +145,8 @@ class RelationProxy(Generic[T], List[T]):
"""
item = self[index]
# Try to delete it, but do it the long way if weakly-referenced thing doesn't exist
# Try to delete it, but do it a long way
# if weakly-referenced thing doesn't exist
try:
self._relation_cache.pop(item.__hash__())
except ReferenceError: