File tree 2 files changed +1
-34
lines changed
2 files changed +1
-34
lines changed Original file line number Diff line number Diff line change @@ -755,8 +755,6 @@ def _field_for_annotated_type(
755
755
is_generic_type (arg )
756
756
and _is_marshmallow_field (typing_extensions .get_origin (arg ))
757
757
)
758
- # Support `partial(mf.List, mf.String)`
759
- or (isinstance (arg , partial ) and _is_marshmallow_field (arg .func ))
760
758
]
761
759
if marshmallow_annotations :
762
760
if len (marshmallow_annotations ) > 1 :
Original file line number Diff line number Diff line change 1
- import dataclasses
2
- import functools
3
1
import sys
4
2
import unittest
5
- from typing import List , Optional
3
+ from typing import Optional
6
4
7
5
import marshmallow
8
6
import marshmallow .fields
@@ -37,32 +35,3 @@ class AnnotatedValue:
37
35
38
36
with self .assertRaises (marshmallow .exceptions .ValidationError ):
39
37
schema .load ({"value" : "notavalidemail" })
40
-
41
- def test_annotated_partial_field (self ) -> None :
42
- """
43
- NewType allowed us to specify a lambda or partial because there was no type inspection.
44
- But with Annotated we do type inspection. Partial still allows us to to type inspection.
45
- """
46
-
47
- @dataclass
48
- class AnnotatedValue :
49
- emails : Annotated [
50
- List [str ],
51
- functools .partial (marshmallow .fields .List , marshmallow .fields .Email ),
52
- ] = dataclasses .field (default_factory = lambda : ["default@email.com" ])
53
-
54
- schema = AnnotatedValue .Schema () # type: ignore[attr-defined]
55
-
56
- self .assertEqual (
57
- schema .load ({}),
58
- AnnotatedValue (emails = ["default@email.com" ]),
59
- )
60
- self .assertEqual (
61
- schema .load ({"emails" : ["test@test.com" ]}),
62
- AnnotatedValue (
63
- emails = ["test@test.com" ],
64
- ),
65
- )
66
-
67
- with self .assertRaises (marshmallow .exceptions .ValidationError ):
68
- schema .load ({"emails" : "notavalidemail" })
You can’t perform that action at this time.
0 commit comments