Enhance Windows Compatibility with Event Loop Policy and Path Resolution (#3986)

Co-authored-by: Suchintan <suchintan@users.noreply.github.com>
Co-authored-by: Shuchang Zheng <wintonzheng0325@gmail.com>
Co-authored-by: Stanislav Novosad <stas@skyvern.com>
This commit is contained in:
Mohamed Khalil
2025-11-20 05:16:16 +02:00
committed by GitHub
parent db68d8a60c
commit d975ca0913
6 changed files with 71 additions and 11 deletions

View File

@@ -7,6 +7,10 @@ from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Set,
import pydantic
from .datetime_utils import serialize_datetime
from .serialization import convert_and_respect_annotation_metadata
from typing_extensions import TypeAlias
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
if IS_PYDANTIC_V2:
@@ -28,9 +32,6 @@ else:
from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef]
from pydantic.typing import is_union as is_union # type: ignore[no-redef]
from .datetime_utils import serialize_datetime
from .serialization import convert_and_respect_annotation_metadata
from typing_extensions import TypeAlias
T = TypeVar("T")
Model = TypeVar("Model", bound=pydantic.BaseModel)
@@ -247,7 +248,7 @@ def _get_model_fields(model: Type["Model"]) -> Mapping[str, PydanticField]:
def _get_field_default(field: PydanticField) -> Any:
try:
value = field.get_default() # type: ignore[union-attr]
except:
except Exception:
value = field.default
if IS_PYDANTIC_V2:
from pydantic_core import PydanticUndefined

View File

@@ -72,7 +72,7 @@ def convert_and_respect_annotation_metadata(
if (
typing_extensions.get_origin(clean_type) == typing.Dict
or typing_extensions.get_origin(clean_type) == dict
or typing_extensions.get_origin(clean_type) is dict
or clean_type == typing.Dict
) and isinstance(object_, typing.Dict):
key_type = typing_extensions.get_args(clean_type)[0]
@@ -92,7 +92,7 @@ def convert_and_respect_annotation_metadata(
if not isinstance(object_, str):
if (
typing_extensions.get_origin(clean_type) == typing.Set
or typing_extensions.get_origin(clean_type) == set
or typing_extensions.get_origin(clean_type) is set
or clean_type == typing.Set
) and isinstance(object_, typing.Set):
inner_type = typing_extensions.get_args(clean_type)[0]
@@ -108,14 +108,14 @@ def convert_and_respect_annotation_metadata(
elif (
(
typing_extensions.get_origin(clean_type) == typing.List
or typing_extensions.get_origin(clean_type) == list
or typing_extensions.get_origin(clean_type) is list
or clean_type == typing.List
)
and isinstance(object_, typing.List)
) or (
(
typing_extensions.get_origin(clean_type) == typing.Sequence
or typing_extensions.get_origin(clean_type) == collections.abc.Sequence
or typing_extensions.get_origin(clean_type) is collections.abc.Sequence
or clean_type == typing.Sequence
)
and isinstance(object_, typing.Sequence)
@@ -131,7 +131,7 @@ def convert_and_respect_annotation_metadata(
for item in object_
]
if typing_extensions.get_origin(clean_type) == typing.Union:
if typing_extensions.get_origin(clean_type) is typing.Union:
# We should be able to ~relatively~ safely try to convert keys against all
# member types in the union, the edge case here is if one member aliases a field
# of the same name to a different name from another member