fix after pydantic update, pin dependencies

This commit is contained in:
collerek
2021-02-28 09:16:36 +01:00
parent 88baf9ebf0
commit 62a6fb9063
6 changed files with 20 additions and 8 deletions

View File

@ -1,3 +1,9 @@
# 0.9.5
## Fixes
* Fix creation of `pydantic` FieldInfo after update of `pydantic` to version >=1.8
* Pin required dependency versions to avoid such situations in the future
# 0.9.4 # 0.9.4
## Fixes ## Fixes

View File

@ -68,7 +68,7 @@ class UndefinedType: # pragma no cover
Undefined = UndefinedType() Undefined = UndefinedType()
__version__ = "0.9.4" __version__ = "0.9.5"
__all__ = [ __all__ = [
"Integer", "Integer",
"BigInteger", "BigInteger",

View File

@ -1,3 +1,4 @@
import inspect
from typing import Any, List, Optional, TYPE_CHECKING, Type, Union from typing import Any, List, Optional, TYPE_CHECKING, Type, Union
import sqlalchemy import sqlalchemy
@ -89,9 +90,10 @@ class BaseField(FieldInfo):
:rtype: bool :rtype: bool
""" """
return ( return (
field_name not in ["default", "default_factory", "alias"] field_name not in ["default", "default_factory", "alias", "allow_mutation"]
and not field_name.startswith("__") and not field_name.startswith("__")
and hasattr(cls, field_name) and hasattr(cls, field_name)
and not callable(getattr(cls, field_name))
) )
@classmethod @classmethod

View File

@ -97,7 +97,7 @@ def populate_pydantic_default_values(attrs: Dict) -> Tuple[Dict, Dict]:
BaseField class. BaseField class.
Trigger conversion of ormar field into pydantic FieldInfo, which has all needed Trigger conversion of ormar field into pydantic FieldInfo, which has all needed
paramaters saved. parameters saved.
Overwrites the annotations of ormar fields to corresponding types declared on Overwrites the annotations of ormar fields to corresponding types declared on
ormar fields (constructed dynamically for relations). ormar fields (constructed dynamically for relations).

View File

@ -45,15 +45,19 @@ setup(
description="A simple async ORM with fastapi in mind and pydantic validation.", description="A simple async ORM with fastapi in mind and pydantic validation.",
long_description=get_long_description(), long_description=get_long_description(),
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
keywords=['orm', 'sqlalchemy', 'fastapi', 'pydantic', 'databases', 'async', 'alembic'], keywords=['orm', 'sqlalchemy', 'fastapi', 'pydantic', 'databases', 'async',
'alembic'],
author="Radosław Drążkiewicz", author="Radosław Drążkiewicz",
author_email="collerek@gmail.com", author_email="collerek@gmail.com",
packages=get_packages(PACKAGE), packages=get_packages(PACKAGE),
package_data={PACKAGE: ["py.typed"]}, package_data={PACKAGE: ["py.typed"]},
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
python_requires=">=3.6",
data_files=[("", ["LICENSE.md"])], data_files=[("", ["LICENSE.md"])],
install_requires=["databases", "pydantic>=1.5", "sqlalchemy", "typing_extensions"], install_requires=["databases>=0.3.2,<=0.4.1", "pydantic>=1.6.1,<=1.8",
"sqlalchemy>=1.3.18,<=1.3.23",
"typing_extensions>=3.7,<=3.7.4.3"],
extras_require={ extras_require={
"postgresql": ["asyncpg", "psycopg2"], "postgresql": ["asyncpg", "psycopg2"],
"mysql": ["aiomysql", "pymysql"], "mysql": ["aiomysql", "pymysql"],

View File

@ -22,7 +22,7 @@ uuid1 = uuid.uuid4()
uuid2 = uuid.uuid4() uuid2 = uuid.uuid4()
class TestEnum(Enum): class EnumTest(Enum):
val1 = "Val1" val1 = "Val1"
val2 = "Val2" val2 = "Val2"
@ -56,7 +56,7 @@ class Organisation(ormar.Model):
) )
random_json: pydantic.Json = ormar.JSON(choices=["aa", '{"aa":"bb"}']) random_json: pydantic.Json = ormar.JSON(choices=["aa", '{"aa":"bb"}'])
random_uuid: uuid.UUID = ormar.UUID(choices=[uuid1, uuid2]) random_uuid: uuid.UUID = ormar.UUID(choices=[uuid1, uuid2])
enum_string: str = ormar.String(max_length=100, choices=list(TestEnum)) enum_string: str = ormar.String(max_length=100, choices=list(EnumTest))
@app.on_event("startup") @app.on_event("startup")
@ -110,7 +110,7 @@ def test_all_endpoints():
"random_decimal": 12.4, "random_decimal": 12.4,
"random_json": '{"aa":"bb"}', "random_json": '{"aa":"bb"}',
"random_uuid": str(uuid1), "random_uuid": str(uuid1),
"enum_string": TestEnum.val1.value, "enum_string": EnumTest.val1.value,
}, },
) )