Skip to content

Commit

Permalink
fix | dpre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-right committed Jul 19, 2023
1 parent e68a2a2 commit 429f2b6
Show file tree
Hide file tree
Showing 18 changed files with 339 additions and 339 deletions.
1 change: 0 additions & 1 deletion beanie/odm/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ async def wrapper(
skip_actions: Optional[List[Union[ActionDirections, str]]] = None,
**kwargs,
):

if skip_actions is None:
skip_actions = []

Expand Down
19 changes: 9 additions & 10 deletions beanie/odm/custom_types/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@


class DecimalCustomAnnotation:

@classmethod
def __get_pydantic_core_schema__(
cls,
_source_type: Any,
_handler: Callable[[Any], core_schema.CoreSchema],
) -> core_schema.CoreSchema:
cls,
_source_type: Any,
_handler: Callable[[Any], core_schema.CoreSchema], # type: ignore
) -> core_schema.CoreSchema: # type: ignore
def validate(value, _: FieldInfo) -> NativeDecimal:
if isinstance(value, Decimal128):
return value.to_decimal()
return value

python_schema = core_schema.general_plain_validator_function(validate)
python_schema = core_schema.general_plain_validator_function(validate) # type: ignore

return core_schema.json_or_python_schema(
json_schema=core_schema.float_schema(),
Expand All @@ -30,11 +29,11 @@ def validate(value, _: FieldInfo) -> NativeDecimal:

@classmethod
def __get_pydantic_json_schema__(
cls, _core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
cls,
_core_schema: core_schema.CoreSchema, # type: ignore
handler: GetJsonSchemaHandler,
) -> JsonSchemaValue:
return handler(core_schema.float_schema())


DecimalAnnotation = Annotated[
NativeDecimal, DecimalCustomAnnotation
]
DecimalAnnotation = Annotated[NativeDecimal, DecimalCustomAnnotation]
Loading

0 comments on commit 429f2b6

Please sign in to comment.