File tree Expand file tree Collapse file tree 2 files changed +1
-34
lines changed Expand file tree Collapse file tree 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(
755755 is_generic_type (arg )
756756 and _is_marshmallow_field (typing_extensions .get_origin (arg ))
757757 )
758- # Support `partial(mf.List, mf.String)`
759- or (isinstance (arg , partial ) and _is_marshmallow_field (arg .func ))
760758 ]
761759 if marshmallow_annotations :
762760 if len (marshmallow_annotations ) > 1 :
Original file line number Diff line number Diff line change 1- import dataclasses
2- import functools
31import sys
42import unittest
5- from typing import List , Optional
3+ from typing import Optional
64
75import marshmallow
86import marshmallow .fields
@@ -37,32 +35,3 @@ class AnnotatedValue:
3735
3836 with self .assertRaises (marshmallow .exceptions .ValidationError ):
3937 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