Skip to content

Commit

Permalink
Merge pull request marshmallow-code#2071 from marshmallow-code/pep_604
Browse files Browse the repository at this point in the history
Use PEP 604 where possible
  • Loading branch information
lafrech committed Dec 5, 2022
2 parents 735f57f + 8168ef2 commit 87dd042
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/marshmallow/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def validate_age(self, data, **kwargs):
from __future__ import annotations

import functools
from typing import Any, Callable, Dict, Optional, Tuple, Union, cast
from typing import Any, Callable, Dict, Tuple, cast

PRE_DUMP = "pre_dump"
POST_DUMP = "post_dump"
Expand All @@ -72,9 +72,7 @@ def validate_age(self, data, **kwargs):


class MarshmallowHook:
__marshmallow_hook__ = (
None
) # type: Optional[Dict[Union[Tuple[str, bool], str], Any]]
__marshmallow_hook__ = None # type: Dict[Tuple[str, bool] | str, Any] | None


def validates(field_name: str) -> Callable[..., Any]:
Expand Down
18 changes: 9 additions & 9 deletions src/marshmallow/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def __init__(
default: typing.Any = missing_,
data_key: str | None = None,
attribute: str | None = None,
validate: None
| (
typing.Callable[[typing.Any], typing.Any]
validate: (
None
| typing.Callable[[typing.Any], typing.Any]
| typing.Iterable[typing.Callable[[typing.Any], typing.Any]]
) = None,
required: bool = False,
Expand Down Expand Up @@ -2024,14 +2024,14 @@ class Function(Field):

def __init__(
self,
serialize: None
| (
typing.Callable[[typing.Any], typing.Any]
serialize: (
None
| typing.Callable[[typing.Any], typing.Any]
| typing.Callable[[typing.Any, dict], typing.Any]
) = None,
deserialize: None
| (
typing.Callable[[typing.Any], typing.Any]
deserialize: (
None
| typing.Callable[[typing.Any], typing.Any]
| typing.Callable[[typing.Any, dict], typing.Any]
) = None,
**kwargs,
Expand Down

0 comments on commit 87dd042

Please sign in to comment.