Compare commits

...

2 Commits

Author SHA1 Message Date
Sebastián Ramírez
1d8d8925fc 🔖 Release version 0.100.0-beta2 2023-06-30 21:50:18 +02:00
Pastukhov Nikita
d5952d6db5 🐛 Fix support for Pydantic v2.0, small changes in their final release (#9771)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-06-30 21:49:10 +02:00
6 changed files with 34 additions and 36 deletions

View File

@@ -1,6 +1,6 @@
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
__version__ = "0.100.0-beta1"
__version__ = "0.100.0-beta2"
from starlette import status as status

View File

@@ -47,8 +47,6 @@ if PYDANTIC_V2:
from pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationError
from pydantic import TypeAdapter
from pydantic import ValidationError as ValidationError
from pydantic._internal._fields import Undefined as Undefined
from pydantic._internal._fields import _UndefinedType
from pydantic._internal._schema_generation_shared import ( # type: ignore[attr-defined]
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
@@ -58,15 +56,16 @@ if PYDANTIC_V2:
from pydantic.json_schema import GenerateJsonSchema as GenerateJsonSchema
from pydantic.json_schema import JsonSchemaValue as JsonSchemaValue
from pydantic_core import CoreSchema as CoreSchema
from pydantic_core import ErrorDetails
from pydantic_core import MultiHostUrl as MultiHostUrl
from pydantic_core import PydanticUndefined, PydanticUndefinedType
from pydantic_core import Url as Url
from pydantic_core.core_schema import (
general_plain_validator_function as general_plain_validator_function,
)
Required = Undefined
UndefinedType = _UndefinedType
Required = PydanticUndefined
Undefined = PydanticUndefined
UndefinedType = PydanticUndefinedType
evaluate_forwardref = eval_type_lenient
Validator = Any
@@ -303,7 +302,6 @@ else:
lenient_issubclass as lenient_issubclass, # noqa: F401
)
ErrorDetails = Dict[str, Any] # type: ignore[assignment,misc]
GetJsonSchemaHandler = Any # type: ignore[assignment,misc]
JsonSchemaValue = Dict[str, Any] # type: ignore[misc]
CoreSchema = Any # type: ignore[assignment,misc]

View File

@@ -145,7 +145,7 @@ def test_path_float_foobar():
{
"type": "float_parsing",
"loc": ["path", "item_id"],
"msg": "Input should be a valid number, unable to parse string as an number",
"msg": "Input should be a valid number, unable to parse string as a number",
"input": "foobar",
"url": match_pydantic_error_url("float_parsing"),
}
@@ -174,7 +174,7 @@ def test_path_float_True():
{
"type": "float_parsing",
"loc": ["path", "item_id"],
"msg": "Input should be a valid number, unable to parse string as an number",
"msg": "Input should be a valid number, unable to parse string as a number",
"input": "True",
"url": match_pydantic_error_url("float_parsing"),
}

View File

@@ -101,7 +101,7 @@ def test_post_with_only_name_price(client: TestClient):
{
"type": "float_parsing",
"loc": ["body", "price"],
"msg": "Input should be a valid number, unable to parse string as an number",
"msg": "Input should be a valid number, unable to parse string as a number",
"input": "twenty",
"url": match_pydantic_error_url("float_parsing"),
}
@@ -240,11 +240,11 @@ def test_post_form_for_json(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": "name=Foo&price=50.5",
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}
@@ -304,12 +304,12 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url(
"dict_attributes_type"
"model_attributes_type"
), # "https://errors.pydantic.dev/0.38.0/v/dict_attributes_type",
}
]
@@ -335,11 +335,11 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}
@@ -363,11 +363,11 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}

View File

@@ -109,7 +109,7 @@ def test_post_with_only_name_price(client: TestClient):
{
"type": "float_parsing",
"loc": ["body", "price"],
"msg": "Input should be a valid number, unable to parse string as an number",
"msg": "Input should be a valid number, unable to parse string as a number",
"input": "twenty",
"url": match_pydantic_error_url("float_parsing"),
}
@@ -252,11 +252,11 @@ def test_post_form_for_json(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": "name=Foo&price=50.5",
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}
@@ -320,11 +320,11 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}
@@ -349,11 +349,11 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}
@@ -377,11 +377,11 @@ def test_wrong_headers(client: TestClient):
{
"detail": [
{
"type": "dict_attributes_type",
"type": "model_attributes_type",
"loc": ["body"],
"msg": "Input should be a valid dictionary or instance to extract fields from",
"msg": "Input should be a valid dictionary or object to extract fields from",
"input": '{"name": "Foo", "price": 50.5}',
"url": match_pydantic_error_url("dict_attributes_type"),
"url": match_pydantic_error_url("model_attributes_type"),
}
]
}

View File

@@ -27,7 +27,7 @@ def test_post_invalid_item():
{
"type": "float_parsing",
"loc": ["body", "price"],
"msg": "Input should be a valid number, unable to parse string as an number",
"msg": "Input should be a valid number, unable to parse string as a number",
"input": "invalid price",
"url": match_pydantic_error_url("float_parsing"),
}