mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 23:07:11 +00:00
core: fix lint 0.3rc (#25993)
This commit is contained in:
@@ -10,7 +10,7 @@ from typing import (
|
|||||||
cast,
|
cast,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from typing_extensions import NotRequired
|
from typing_extensions import NotRequired
|
||||||
|
|
||||||
from langchain_core.utils.pydantic import v1_repr
|
from langchain_core.utils.pydantic import v1_repr
|
||||||
|
@@ -5,8 +5,8 @@ from json import JSONDecodeError
|
|||||||
from typing import Any, List, Optional, Type, TypeVar, Union
|
from typing import Any, List, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
import jsonpatch # type: ignore[import]
|
import jsonpatch # type: ignore[import]
|
||||||
import pydantic
|
import pydantic
|
||||||
from pydantic import SkipValidation
|
from pydantic import SkipValidation
|
||||||
from typing_extensions import Annotated
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
@@ -24,7 +24,7 @@ if PYDANTIC_MAJOR_VERSION < 2:
|
|||||||
PydanticBaseModel = pydantic.BaseModel
|
PydanticBaseModel = pydantic.BaseModel
|
||||||
|
|
||||||
else:
|
else:
|
||||||
from pydantic.v1 import BaseModel
|
from pydantic.v1 import BaseModel
|
||||||
|
|
||||||
# Union type needs to be last assignment to PydanticBaseModel to make mypy happy.
|
# Union type needs to be last assignment to PydanticBaseModel to make mypy happy.
|
||||||
PydanticBaseModel = Union[BaseModel, pydantic.BaseModel] # type: ignore
|
PydanticBaseModel = Union[BaseModel, pydantic.BaseModel] # type: ignore
|
||||||
|
@@ -3,7 +3,7 @@ import json
|
|||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from pydantic import SkipValidation, ValidationError
|
from pydantic import SkipValidation, ValidationError
|
||||||
from typing_extensions import Annotated
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
from typing import Generic, List, Optional, Type
|
from typing import Generic, List, Optional, Type
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from pydantic import SkipValidation
|
from pydantic import SkipValidation
|
||||||
from typing_extensions import Annotated
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
|
@@ -31,7 +31,7 @@ from typing import (
|
|||||||
cast,
|
cast,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, RootModel
|
from pydantic import BaseModel, ConfigDict, RootModel
|
||||||
from pydantic import create_model as _create_model_base # pydantic :ignore
|
from pydantic import create_model as _create_model_base # pydantic :ignore
|
||||||
from pydantic.json_schema import (
|
from pydantic.json_schema import (
|
||||||
DEFAULT_REF_TEMPLATE,
|
DEFAULT_REF_TEMPLATE,
|
||||||
|
@@ -196,7 +196,7 @@ def convert_python_function_to_openai_function(
|
|||||||
|
|
||||||
def _convert_typed_dict_to_openai_function(typed_dict: Type) -> FunctionDescription:
|
def _convert_typed_dict_to_openai_function(typed_dict: Type) -> FunctionDescription:
|
||||||
visited: Dict = {}
|
visited: Dict = {}
|
||||||
from pydantic.v1 import BaseModel
|
from pydantic.v1 import BaseModel
|
||||||
|
|
||||||
model = cast(
|
model = cast(
|
||||||
Type[BaseModel],
|
Type[BaseModel],
|
||||||
@@ -214,8 +214,8 @@ def _convert_any_typed_dicts_to_pydantic(
|
|||||||
visited: Dict,
|
visited: Dict,
|
||||||
depth: int = 0,
|
depth: int = 0,
|
||||||
) -> Type:
|
) -> Type:
|
||||||
from pydantic.v1 import Field as Field_v1
|
from pydantic.v1 import Field as Field_v1
|
||||||
from pydantic.v1 import create_model as create_model_v1
|
from pydantic.v1 import create_model as create_model_v1
|
||||||
|
|
||||||
if type_ in visited:
|
if type_ in visited:
|
||||||
return visited[type_]
|
return visited[type_]
|
||||||
|
@@ -7,10 +7,10 @@ import textwrap
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union, overload
|
from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union, overload
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from pydantic import BaseModel, root_validator
|
from pydantic import BaseModel, root_validator
|
||||||
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
||||||
from pydantic_core import core_schema
|
from pydantic_core import core_schema
|
||||||
|
|
||||||
|
|
||||||
def get_pydantic_major_version() -> int:
|
def get_pydantic_major_version() -> int:
|
||||||
@@ -77,13 +77,13 @@ def is_basemodel_subclass(cls: Type) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if PYDANTIC_MAJOR_VERSION == 1:
|
if PYDANTIC_MAJOR_VERSION == 1:
|
||||||
from pydantic import BaseModel as BaseModelV1Proper
|
from pydantic import BaseModel as BaseModelV1Proper
|
||||||
|
|
||||||
if issubclass(cls, BaseModelV1Proper):
|
if issubclass(cls, BaseModelV1Proper):
|
||||||
return True
|
return True
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
if issubclass(cls, BaseModelV2):
|
if issubclass(cls, BaseModelV2):
|
||||||
return True
|
return True
|
||||||
@@ -105,13 +105,13 @@ def is_basemodel_instance(obj: Any) -> bool:
|
|||||||
* pydantic.v1.BaseModel in Pydantic 2.x
|
* pydantic.v1.BaseModel in Pydantic 2.x
|
||||||
"""
|
"""
|
||||||
if PYDANTIC_MAJOR_VERSION == 1:
|
if PYDANTIC_MAJOR_VERSION == 1:
|
||||||
from pydantic import BaseModel as BaseModelV1Proper
|
from pydantic import BaseModel as BaseModelV1Proper
|
||||||
|
|
||||||
if isinstance(obj, BaseModelV1Proper):
|
if isinstance(obj, BaseModelV1Proper):
|
||||||
return True
|
return True
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
if isinstance(obj, BaseModelV2):
|
if isinstance(obj, BaseModelV2):
|
||||||
return True
|
return True
|
||||||
@@ -222,9 +222,9 @@ def _create_subset_model_v1(
|
|||||||
) -> Type[BaseModel]:
|
) -> Type[BaseModel]:
|
||||||
"""Create a pydantic model with only a subset of model's fields."""
|
"""Create a pydantic model with only a subset of model's fields."""
|
||||||
if PYDANTIC_MAJOR_VERSION == 1:
|
if PYDANTIC_MAJOR_VERSION == 1:
|
||||||
from pydantic import create_model
|
from pydantic import create_model
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic.v1 import create_model # type: ignore
|
from pydantic.v1 import create_model # type: ignore
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
f"Unsupported pydantic version: {PYDANTIC_MAJOR_VERSION}"
|
f"Unsupported pydantic version: {PYDANTIC_MAJOR_VERSION}"
|
||||||
@@ -259,8 +259,8 @@ def _create_subset_model_v2(
|
|||||||
fn_description: Optional[str] = None,
|
fn_description: Optional[str] = None,
|
||||||
) -> Type[pydantic.BaseModel]:
|
) -> Type[pydantic.BaseModel]:
|
||||||
"""Create a pydantic model with a subset of the model fields."""
|
"""Create a pydantic model with a subset of the model fields."""
|
||||||
from pydantic import create_model
|
from pydantic import create_model
|
||||||
from pydantic.fields import FieldInfo
|
from pydantic.fields import FieldInfo
|
||||||
|
|
||||||
descriptions_ = descriptions or {}
|
descriptions_ = descriptions or {}
|
||||||
fields = {}
|
fields = {}
|
||||||
@@ -299,7 +299,7 @@ def _create_subset_model(
|
|||||||
fn_description=fn_description,
|
fn_description=fn_description,
|
||||||
)
|
)
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
if issubclass(model, BaseModelV1):
|
if issubclass(model, BaseModelV1):
|
||||||
return _create_subset_model_v1(
|
return _create_subset_model_v1(
|
||||||
|
@@ -531,7 +531,7 @@ async def test_partial_pydantic_output_parser_async() -> None:
|
|||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="This test is for pydantic 2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="This test is for pydantic 2")
|
||||||
def test_parse_with_different_pydantic_2_v1() -> None:
|
def test_parse_with_different_pydantic_2_v1() -> None:
|
||||||
"""Test with pydantic.v1.BaseModel from pydantic 2."""
|
"""Test with pydantic.v1.BaseModel from pydantic 2."""
|
||||||
import pydantic
|
import pydantic
|
||||||
|
|
||||||
class Forecast(pydantic.v1.BaseModel):
|
class Forecast(pydantic.v1.BaseModel):
|
||||||
temperature: int
|
temperature: int
|
||||||
@@ -566,7 +566,7 @@ def test_parse_with_different_pydantic_2_v1() -> None:
|
|||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="This test is for pydantic 2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="This test is for pydantic 2")
|
||||||
def test_parse_with_different_pydantic_2_proper() -> None:
|
def test_parse_with_different_pydantic_2_proper() -> None:
|
||||||
"""Test with pydantic.BaseModel from pydantic 2."""
|
"""Test with pydantic.BaseModel from pydantic 2."""
|
||||||
import pydantic
|
import pydantic
|
||||||
|
|
||||||
class Forecast(pydantic.BaseModel):
|
class Forecast(pydantic.BaseModel):
|
||||||
temperature: int
|
temperature: int
|
||||||
@@ -601,7 +601,7 @@ def test_parse_with_different_pydantic_2_proper() -> None:
|
|||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="This test is for pydantic 1")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="This test is for pydantic 1")
|
||||||
def test_parse_with_different_pydantic_1_proper() -> None:
|
def test_parse_with_different_pydantic_1_proper() -> None:
|
||||||
"""Test with pydantic.BaseModel from pydantic 1."""
|
"""Test with pydantic.BaseModel from pydantic 1."""
|
||||||
import pydantic
|
import pydantic
|
||||||
|
|
||||||
class Forecast(pydantic.BaseModel):
|
class Forecast(pydantic.BaseModel):
|
||||||
temperature: int
|
temperature: int
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
import pytest
|
import pytest
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from pydantic.v1 import BaseModel as V1BaseModel
|
from pydantic.v1 import BaseModel as V1BaseModel
|
||||||
|
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.language_models import ParrotFakeChatModel
|
from langchain_core.language_models import ParrotFakeChatModel
|
||||||
|
@@ -455,7 +455,7 @@ def test_get_input_schema_input_dict() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_get_input_schema_input_messages() -> None:
|
def test_get_input_schema_input_messages() -> None:
|
||||||
from pydantic import RootModel
|
from pydantic import RootModel
|
||||||
|
|
||||||
RunnableWithMessageHistoryInput = RootModel[Sequence[BaseMessage]]
|
RunnableWithMessageHistoryInput = RootModel[Sequence[BaseMessage]]
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ from typing import (
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pydantic import BaseModel, Field, ValidationError
|
from pydantic import BaseModel, Field, ValidationError
|
||||||
from pydantic import BaseModel as BaseModelProper
|
from pydantic import BaseModel as BaseModelProper
|
||||||
from typing_extensions import Annotated, TypedDict, TypeVar
|
from typing_extensions import Annotated, TypedDict, TypeVar
|
||||||
|
|
||||||
from langchain_core import tools
|
from langchain_core import tools
|
||||||
@@ -1572,7 +1572,7 @@ def generate_models() -> List[Any]:
|
|||||||
|
|
||||||
def generate_backwards_compatible_v1() -> List[Any]:
|
def generate_backwards_compatible_v1() -> List[Any]:
|
||||||
"""Generate a model with pydantic 2 from the v1 namespace."""
|
"""Generate a model with pydantic 2 from the v1 namespace."""
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
class FooV1Namespace(BaseModelV1):
|
class FooV1Namespace(BaseModelV1):
|
||||||
a: int
|
a: int
|
||||||
@@ -1629,7 +1629,7 @@ def test_args_schema_explicitly_typed() -> None:
|
|||||||
is a pydantic 1 model!
|
is a pydantic 1 model!
|
||||||
"""
|
"""
|
||||||
# Check with whatever pydantic model is passed in and not via v1 namespace
|
# Check with whatever pydantic model is passed in and not via v1 namespace
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
class Foo(BaseModel):
|
class Foo(BaseModel):
|
||||||
a: int
|
a: int
|
||||||
@@ -1873,9 +1873,9 @@ def test__get_all_basemodel_annotations_v1() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Testing pydantic v2.")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Testing pydantic v2.")
|
||||||
def test_tool_args_schema_pydantic_v2_with_metadata() -> None:
|
def test_tool_args_schema_pydantic_v2_with_metadata() -> None:
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic import Field as FieldV2
|
from pydantic import Field as FieldV2
|
||||||
from pydantic import ValidationError as ValidationErrorV2
|
from pydantic import ValidationError as ValidationErrorV2
|
||||||
|
|
||||||
class Foo(BaseModelV2):
|
class Foo(BaseModelV2):
|
||||||
x: List[int] = FieldV2(
|
x: List[int] = FieldV2(
|
||||||
|
@@ -94,12 +94,12 @@ def test_with_aliases() -> None:
|
|||||||
def test_is_basemodel_subclass() -> None:
|
def test_is_basemodel_subclass() -> None:
|
||||||
"""Test pydantic."""
|
"""Test pydantic."""
|
||||||
if PYDANTIC_MAJOR_VERSION == 1:
|
if PYDANTIC_MAJOR_VERSION == 1:
|
||||||
from pydantic import BaseModel as BaseModelV1Proper
|
from pydantic import BaseModel as BaseModelV1Proper
|
||||||
|
|
||||||
assert is_basemodel_subclass(BaseModelV1Proper)
|
assert is_basemodel_subclass(BaseModelV1Proper)
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
assert is_basemodel_subclass(BaseModelV2)
|
assert is_basemodel_subclass(BaseModelV2)
|
||||||
|
|
||||||
@@ -111,15 +111,15 @@ def test_is_basemodel_subclass() -> None:
|
|||||||
def test_is_basemodel_instance() -> None:
|
def test_is_basemodel_instance() -> None:
|
||||||
"""Test pydantic."""
|
"""Test pydantic."""
|
||||||
if PYDANTIC_MAJOR_VERSION == 1:
|
if PYDANTIC_MAJOR_VERSION == 1:
|
||||||
from pydantic import BaseModel as BaseModelV1Proper
|
from pydantic import BaseModel as BaseModelV1Proper
|
||||||
|
|
||||||
class FooV1(BaseModelV1Proper):
|
class FooV1(BaseModelV1Proper):
|
||||||
x: int
|
x: int
|
||||||
|
|
||||||
assert is_basemodel_instance(FooV1(x=5))
|
assert is_basemodel_instance(FooV1(x=5))
|
||||||
elif PYDANTIC_MAJOR_VERSION == 2:
|
elif PYDANTIC_MAJOR_VERSION == 2:
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic.v1 import BaseModel as BaseModelV1
|
from pydantic.v1 import BaseModel as BaseModelV1
|
||||||
|
|
||||||
class Foo(BaseModelV2):
|
class Foo(BaseModelV2):
|
||||||
x: int
|
x: int
|
||||||
@@ -137,8 +137,8 @@ def test_is_basemodel_instance() -> None:
|
|||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
||||||
def test_with_field_metadata() -> None:
|
def test_with_field_metadata() -> None:
|
||||||
"""Test pydantic with field metadata"""
|
"""Test pydantic with field metadata"""
|
||||||
from pydantic import BaseModel as BaseModelV2
|
from pydantic import BaseModel as BaseModelV2
|
||||||
from pydantic import Field as FieldV2
|
from pydantic import Field as FieldV2
|
||||||
|
|
||||||
class Foo(BaseModelV2):
|
class Foo(BaseModelV2):
|
||||||
x: List[int] = FieldV2(
|
x: List[int] = FieldV2(
|
||||||
@@ -165,7 +165,7 @@ def test_with_field_metadata() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="Only tests Pydantic v1")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="Only tests Pydantic v1")
|
||||||
def test_fields_pydantic_v1() -> None:
|
def test_fields_pydantic_v1() -> None:
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
class Foo(BaseModel):
|
class Foo(BaseModel):
|
||||||
x: int
|
x: int
|
||||||
@@ -176,7 +176,7 @@ def test_fields_pydantic_v1() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
||||||
def test_fields_pydantic_v2_proper() -> None:
|
def test_fields_pydantic_v2_proper() -> None:
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
class Foo(BaseModel):
|
class Foo(BaseModel):
|
||||||
x: int
|
x: int
|
||||||
@@ -187,7 +187,7 @@ def test_fields_pydantic_v2_proper() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
|
||||||
def test_fields_pydantic_v1_from_2() -> None:
|
def test_fields_pydantic_v1_from_2() -> None:
|
||||||
from pydantic.v1 import BaseModel
|
from pydantic.v1 import BaseModel
|
||||||
|
|
||||||
class Foo(BaseModel):
|
class Foo(BaseModel):
|
||||||
x: int
|
x: int
|
||||||
|
@@ -221,8 +221,8 @@ def test_guard_import_failure(
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Requires pydantic 2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Requires pydantic 2")
|
||||||
def test_get_pydantic_field_names_v1_in_2() -> None:
|
def test_get_pydantic_field_names_v1_in_2() -> None:
|
||||||
from pydantic.v1 import BaseModel as PydanticV1BaseModel
|
from pydantic.v1 import BaseModel as PydanticV1BaseModel
|
||||||
from pydantic.v1 import Field
|
from pydantic.v1 import Field
|
||||||
|
|
||||||
class PydanticV1Model(PydanticV1BaseModel):
|
class PydanticV1Model(PydanticV1BaseModel):
|
||||||
field1: str
|
field1: str
|
||||||
@@ -236,7 +236,7 @@ def test_get_pydantic_field_names_v1_in_2() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Requires pydantic 2")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Requires pydantic 2")
|
||||||
def test_get_pydantic_field_names_v2_in_2() -> None:
|
def test_get_pydantic_field_names_v2_in_2() -> None:
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
class PydanticModel(BaseModel):
|
class PydanticModel(BaseModel):
|
||||||
field1: str
|
field1: str
|
||||||
@@ -250,7 +250,7 @@ def test_get_pydantic_field_names_v2_in_2() -> None:
|
|||||||
|
|
||||||
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="Requires pydantic 1")
|
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 1, reason="Requires pydantic 1")
|
||||||
def test_get_pydantic_field_names_v1() -> None:
|
def test_get_pydantic_field_names_v1() -> None:
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
class PydanticModel(BaseModel):
|
class PydanticModel(BaseModel):
|
||||||
field1: str
|
field1: str
|
||||||
|
Reference in New Issue
Block a user