core: fix lint 0.3rc (#25993)

This commit is contained in:
Erick Friis
2024-09-03 14:13:52 -07:00
committed by GitHub
parent 29413a22e1
commit 0da201c1d5
13 changed files with 53 additions and 53 deletions

View File

@@ -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")
def test_parse_with_different_pydantic_2_v1() -> None:
"""Test with pydantic.v1.BaseModel from pydantic 2."""
import pydantic
import pydantic
class Forecast(pydantic.v1.BaseModel):
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")
def test_parse_with_different_pydantic_2_proper() -> None:
"""Test with pydantic.BaseModel from pydantic 2."""
import pydantic
import pydantic
class Forecast(pydantic.BaseModel):
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")
def test_parse_with_different_pydantic_1_proper() -> None:
"""Test with pydantic.BaseModel from pydantic 1."""
import pydantic
import pydantic
class Forecast(pydantic.BaseModel):
temperature: int

View File

@@ -3,10 +3,10 @@
from enum import Enum
from typing import Literal, Optional
import pydantic
import pydantic
import pytest
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.language_models import ParrotFakeChatModel

View File

@@ -455,7 +455,7 @@ def test_get_input_schema_input_dict() -> None:
def test_get_input_schema_input_messages() -> None:
from pydantic import RootModel
from pydantic import RootModel
RunnableWithMessageHistoryInput = RootModel[Sequence[BaseMessage]]

View File

@@ -23,7 +23,7 @@ from typing import (
import pytest
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 langchain_core import tools
@@ -1572,7 +1572,7 @@ def generate_models() -> List[Any]:
def generate_backwards_compatible_v1() -> List[Any]:
"""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):
a: int
@@ -1629,7 +1629,7 @@ def test_args_schema_explicitly_typed() -> None:
is a pydantic 1 model!
"""
# Check with whatever pydantic model is passed in and not via v1 namespace
from pydantic import BaseModel
from pydantic import BaseModel
class Foo(BaseModel):
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.")
def test_tool_args_schema_pydantic_v2_with_metadata() -> None:
from pydantic import BaseModel as BaseModelV2
from pydantic import Field as FieldV2
from pydantic import ValidationError as ValidationErrorV2
from pydantic import BaseModel as BaseModelV2
from pydantic import Field as FieldV2
from pydantic import ValidationError as ValidationErrorV2
class Foo(BaseModelV2):
x: List[int] = FieldV2(

View File

@@ -94,12 +94,12 @@ def test_with_aliases() -> None:
def test_is_basemodel_subclass() -> None:
"""Test pydantic."""
if PYDANTIC_MAJOR_VERSION == 1:
from pydantic import BaseModel as BaseModelV1Proper
from pydantic import BaseModel as BaseModelV1Proper
assert is_basemodel_subclass(BaseModelV1Proper)
elif PYDANTIC_MAJOR_VERSION == 2:
from pydantic import BaseModel as BaseModelV2
from pydantic.v1 import BaseModel as BaseModelV1
from pydantic import BaseModel as BaseModelV2
from pydantic.v1 import BaseModel as BaseModelV1
assert is_basemodel_subclass(BaseModelV2)
@@ -111,15 +111,15 @@ def test_is_basemodel_subclass() -> None:
def test_is_basemodel_instance() -> None:
"""Test pydantic."""
if PYDANTIC_MAJOR_VERSION == 1:
from pydantic import BaseModel as BaseModelV1Proper
from pydantic import BaseModel as BaseModelV1Proper
class FooV1(BaseModelV1Proper):
x: int
assert is_basemodel_instance(FooV1(x=5))
elif PYDANTIC_MAJOR_VERSION == 2:
from pydantic import BaseModel as BaseModelV2
from pydantic.v1 import BaseModel as BaseModelV1
from pydantic import BaseModel as BaseModelV2
from pydantic.v1 import BaseModel as BaseModelV1
class Foo(BaseModelV2):
x: int
@@ -137,8 +137,8 @@ def test_is_basemodel_instance() -> None:
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
def test_with_field_metadata() -> None:
"""Test pydantic with field metadata"""
from pydantic import BaseModel as BaseModelV2
from pydantic import Field as FieldV2
from pydantic import BaseModel as BaseModelV2
from pydantic import Field as FieldV2
class Foo(BaseModelV2):
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")
def test_fields_pydantic_v1() -> None:
from pydantic import BaseModel
from pydantic import BaseModel
class Foo(BaseModel):
x: int
@@ -176,7 +176,7 @@ def test_fields_pydantic_v1() -> None:
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Only tests Pydantic v2")
def test_fields_pydantic_v2_proper() -> None:
from pydantic import BaseModel
from pydantic import BaseModel
class Foo(BaseModel):
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")
def test_fields_pydantic_v1_from_2() -> None:
from pydantic.v1 import BaseModel
from pydantic.v1 import BaseModel
class Foo(BaseModel):
x: int

View File

@@ -221,8 +221,8 @@ def test_guard_import_failure(
@pytest.mark.skipif(PYDANTIC_MAJOR_VERSION != 2, reason="Requires pydantic 2")
def test_get_pydantic_field_names_v1_in_2() -> None:
from pydantic.v1 import BaseModel as PydanticV1BaseModel
from pydantic.v1 import Field
from pydantic.v1 import BaseModel as PydanticV1BaseModel
from pydantic.v1 import Field
class PydanticV1Model(PydanticV1BaseModel):
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")
def test_get_pydantic_field_names_v2_in_2() -> None:
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field
class PydanticModel(BaseModel):
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")
def test_get_pydantic_field_names_v1() -> None:
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field
class PydanticModel(BaseModel):
field1: str