Skip to content

Commit

Permalink
fix: Solve the problem caused by fixing syntax style
Browse files Browse the repository at this point in the history
  • Loading branch information
ox01024 committed Sep 14, 2024
1 parent d4adc1f commit f1955b3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

def parse_date(value: date | StrBytesIntFloat) -> date: ...

def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: ...
def parse_datetime(
value: Union[datetime, StrBytesIntFloat]) -> datetime: ...

def get_args(t: type[Any]) -> tuple[Any, ...]: ...

Expand All @@ -39,9 +40,23 @@ def is_typeddict(type_: type[Any]) -> bool: ...

else:
if PYDANTIC_V2:
pass
from pydantic.v1.typing import ( # noqa: I001
get_args as get_args, # noqa: PLC0414
is_union as is_union, # noqa: PLC0414
get_origin as get_origin, # noqa: PLC0414
is_typeddict as is_typeddict, # noqa: PLC0414
is_literal_type as is_literal_type, # noqa: PLC0414
)
from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime # noqa: PLC0414
else:
pass
from pydantic.typing import ( # noqa: I001
get_args as get_args, # noqa: PLC0414
is_union as is_union, # noqa: PLC0414
get_origin as get_origin, # noqa: PLC0414
is_typeddict as is_typeddict, # noqa: PLC0414
is_literal_type as is_literal_type, # noqa: PLC0414
)
from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime # noqa: PLC0414


# refactored config
Expand All @@ -60,7 +75,8 @@ def parse_obj(model: type[_ModelT], value: object) -> _ModelT:
if PYDANTIC_V2:
return model.model_validate(value)
else:
return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
# pyright: ignore[reportDeprecated, reportUnnecessaryCast]
return cast(_ModelT, model.parse_obj(value))


def field_is_required(field: FieldInfo) -> bool:
Expand Down Expand Up @@ -139,19 +155,22 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
# generic models
if TYPE_CHECKING:

class GenericModel(pydantic.BaseModel): ...
class GenericModel(pydantic.BaseModel):
...

else:
if PYDANTIC_V2:
# there no longer needs to be a distinction in v2 but
# we still have to create our own subclass to avoid
# inconsistent MRO ordering errors
class GenericModel(pydantic.BaseModel): ...
class GenericModel(pydantic.BaseModel):
...

else:
import pydantic.generics

class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel):
...


# cached properties
Expand All @@ -173,10 +192,12 @@ class typed_cached_property(Generic[_T]): # noqa: N801
def __init__(self, func: Callable[[Any], _T]) -> None: ...

@overload
def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ...
def __get__(self, instance: None,
owner: type[Any] | None = None) -> Self: ...

@overload
def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ...
def __get__(self, instance: object,
owner: type[Any] | None = None) -> _T: ...

def __get__(self, instance: object, owner: type[Any] | None = None) -> _T | Self:
raise NotImplementedError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ def decode_line(self, line: str):

field, _p, value = line.partition(":")

if value.startswith(" "):
value = value[1:]
value = value.removeprefix(" ")
if field == "data":
self._data.append(value)
elif field == "event":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
from ._transform import (
PropertyInfo,
async_maybe_transform,
async_transform,
maybe_transform,
transform,

from ._utils import ( # noqa: I001
remove_notgiven_indict as remove_notgiven_indict, # noqa: PLC0414
flatten as flatten, # noqa: PLC0414
is_dict as is_dict, # noqa: PLC0414
is_list as is_list, # noqa: PLC0414
is_given as is_given, # noqa: PLC0414
is_tuple as is_tuple, # noqa: PLC0414
is_mapping as is_mapping, # noqa: PLC0414
is_tuple_t as is_tuple_t, # noqa: PLC0414
parse_date as parse_date, # noqa: PLC0414
is_iterable as is_iterable, # noqa: PLC0414
is_sequence as is_sequence, # noqa: PLC0414
coerce_float as coerce_float, # noqa: PLC0414
is_mapping_t as is_mapping_t, # noqa: PLC0414
removeprefix as removeprefix, # noqa: PLC0414
removesuffix as removesuffix, # noqa: PLC0414
extract_files as extract_files, # noqa: PLC0414
is_sequence_t as is_sequence_t, # noqa: PLC0414
required_args as required_args, # noqa: PLC0414
coerce_boolean as coerce_boolean, # noqa: PLC0414
coerce_integer as coerce_integer, # noqa: PLC0414
file_from_path as file_from_path, # noqa: PLC0414
parse_datetime as parse_datetime, # noqa: PLC0414
strip_not_given as strip_not_given, # noqa: PLC0414
deepcopy_minimal as deepcopy_minimal, # noqa: PLC0414
get_async_library as get_async_library, # noqa: PLC0414
maybe_coerce_float as maybe_coerce_float, # noqa: PLC0414
get_required_header as get_required_header, # noqa: PLC0414
maybe_coerce_boolean as maybe_coerce_boolean, # noqa: PLC0414
maybe_coerce_integer as maybe_coerce_integer, # noqa: PLC0414
drop_prefix_image_data as drop_prefix_image_data, # noqa: PLC0414
)


from ._typing import (
extract_type_arg,
extract_type_var_from_base,
is_annotated_type,
is_iterable_type,
is_list_type,
is_required_type,
is_union_type,
strip_annotated_type,
is_list_type as is_list_type, # noqa: PLC0414
is_union_type as is_union_type, # noqa: PLC0414
extract_type_arg as extract_type_arg, # noqa: PLC0414
is_iterable_type as is_iterable_type, # noqa: PLC0414
is_required_type as is_required_type, # noqa: PLC0414
is_annotated_type as is_annotated_type, # noqa: PLC0414
strip_annotated_type as strip_annotated_type, # noqa: PLC0414
extract_type_var_from_base as extract_type_var_from_base, # noqa: PLC0414
)
from ._utils import (
coerce_boolean,
coerce_float,
coerce_integer,
deepcopy_minimal,
drop_prefix_image_data,
extract_files,
file_from_path,
flatten,
get_async_library,
get_required_header,
is_dict,
is_given,
is_iterable,
is_list,
is_mapping,
is_mapping_t,
is_sequence,
is_sequence_t,
is_tuple,
is_tuple_t,
maybe_coerce_boolean,
maybe_coerce_float,
maybe_coerce_integer,
parse_date,
parse_datetime,
remove_notgiven_indict,
removeprefix,
removesuffix,
required_args,
strip_not_given,

from ._transform import (
PropertyInfo as PropertyInfo, # noqa: PLC0414
transform as transform, # noqa: PLC0414
async_transform as async_transform, # noqa: PLC0414
maybe_transform as maybe_transform, # noqa: PLC0414
async_maybe_transform as async_maybe_transform, # noqa: PLC0414
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import sniffio

from .._base_compat import parse_date as parse_date # noqa: PLC0414
from .._base_compat import parse_datetime as parse_datetime # noqa: PLC0414
from .._base_type import FileTypes, Headers, HeadersLike, NotGiven, NotGivenOr


Expand Down
1 change: 0 additions & 1 deletion api/core/tools/provider/builtin/cogview/tools/cogview3.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def _invoke(
quality=quality,
response_format="b64_json",
)
print(response.data)
result = []
for image in response.data:
result.append(self.create_image_message(image=image.url))
Expand Down

0 comments on commit f1955b3

Please sign in to comment.