Skip to content

Commit 4036cd7

Browse files
committed
Merge remote-tracking branch 'origin' into os/generic-dataclasses
2 parents f9d894b + 9acc769 commit 4036cd7

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010

1111
runs-on: ubuntu-latest
1212
strategy:
13+
fail-fast: false
1314
matrix:
1415
python_version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.9"]
1516

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.2.0
3+
rev: v3.2.3
44
hooks:
55
- id: pyupgrade
66
args: ["--py36-plus"]
@@ -9,13 +9,14 @@ repos:
99
hooks:
1010
- id: black
1111
language_version: python3
12-
- repo: https://gitlab.com/pycqa/flake8
12+
- repo: https://github.com/PyCQA/flake8
13+
# Flake8==6.0.0 requires python>=3.8.1
1314
rev: 5.0.4
1415
hooks:
1516
- id: flake8
1617
additional_dependencies: ['flake8-bugbear==22.10.27']
1718
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v0.982
19+
rev: v0.991
1920
hooks:
2021
- id: mypy
2122
additional_dependencies: [marshmallow-enum,typeguard,marshmallow]

marshmallow_dataclass/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def dataclass(
116116
# underscore. The presence of _cls is used to detect if this
117117
# decorator is being called with parameters or not.
118118
def dataclass(
119-
_cls: Type[_U] = None,
119+
_cls: Optional[Type[_U]] = None,
120120
*,
121121
repr: bool = True,
122122
eq: bool = True,
@@ -173,16 +173,16 @@ def add_schema(_cls: Type[_U]) -> Type[_U]:
173173

174174
@overload
175175
def add_schema(
176-
base_schema: Type[marshmallow.Schema] = None,
176+
base_schema: Optional[Type[marshmallow.Schema]] = None,
177177
) -> Callable[[Type[_U]], Type[_U]]:
178178
...
179179

180180

181181
@overload
182182
def add_schema(
183183
_cls: Type[_U],
184-
base_schema: Type[marshmallow.Schema] = None,
185-
cls_frame: types.FrameType = None,
184+
base_schema: Optional[Type[marshmallow.Schema]] = None,
185+
cls_frame: Optional[types.FrameType] = None,
186186
) -> Type[_U]:
187187
...
188188

@@ -224,7 +224,7 @@ def decorator(clazz: Type[_U]) -> Type[_U]:
224224
def class_schema(
225225
clazz: type,
226226
base_schema: Optional[Type[marshmallow.Schema]] = None,
227-
clazz_frame: types.FrameType = None,
227+
clazz_frame: Optional[types.FrameType] = None,
228228
) -> Type[marshmallow.Schema]:
229229
"""
230230
Convert a class to a marshmallow schema
@@ -371,7 +371,7 @@ def _dataclass_fields(clazz: type) -> Tuple[dataclasses.Field, ...]:
371371
def _internal_class_schema(
372372
clazz: type,
373373
base_schema: Optional[Type[marshmallow.Schema]] = None,
374-
clazz_frame: types.FrameType = None,
374+
clazz_frame: Optional[types.FrameType] = None,
375375
generic_params_to_args: Optional[Tuple[Tuple[type, type], ...]] = None,
376376
) -> Type[marshmallow.Schema]:
377377
# generic aliases do not have a __name__ prior python 3.10
@@ -642,7 +642,7 @@ def _field_for_generic_type(
642642
def field_for_schema(
643643
typ: type,
644644
default=marshmallow.missing,
645-
metadata: Mapping[str, Any] = None,
645+
metadata: Optional[Mapping[str, Any]] = None,
646646
base_schema: Optional[Type[marshmallow.Schema]] = None,
647647
typ_frame: Optional[types.FrameType] = None,
648648
generic_params_to_args: Optional[Tuple[Tuple[type, type], ...]] = None,
@@ -795,7 +795,7 @@ def _base_schema(
795795
# Remove `type: ignore` when mypy handles dynamic base classes
796796
# https://github.com/python/mypy/issues/2813
797797
class BaseSchema(base_schema or marshmallow.Schema): # type: ignore
798-
def load(self, data: Mapping, *, many: bool = None, **kwargs):
798+
def load(self, data: Mapping, *, many: Optional[bool] = None, **kwargs):
799799
all_loaded = super().load(data, many=many, **kwargs)
800800
many = self.many if many is None else bool(many)
801801
if many:

marshmallow_dataclass/lazy_class_attribute.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable
1+
from typing import Any, Callable, Optional
22

33

44
__all__ = ("lazy_class_attribute",)
@@ -13,7 +13,10 @@ class LazyClassAttribute:
1313
__slots__ = ("func", "name", "called", "forward_value")
1414

1515
def __init__(
16-
self, func: Callable[..., Any], name: str = None, forward_value: Any = None
16+
self,
17+
func: Callable[..., Any],
18+
name: Optional[str] = None,
19+
forward_value: Any = None,
1720
):
1821
self.func = func
1922
self.name = name

tests/test_class_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
try:
88
from typing import Final, Literal # type: ignore[attr-defined]
99
except ImportError:
10-
from typing_extensions import Final, Literal # type: ignore[misc]
10+
from typing_extensions import Final, Literal # type: ignore[assignment]
1111

1212
import dataclasses
1313
from marshmallow import Schema, ValidationError

tests/test_field_for_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
try:
99
from typing import Final, Literal # type: ignore[attr-defined]
1010
except ImportError:
11-
from typing_extensions import Final, Literal # type: ignore[misc]
11+
from typing_extensions import Final, Literal # type: ignore[assignment]
1212

1313
from marshmallow import fields, Schema, validate
1414

0 commit comments

Comments
 (0)