@@ -784,6 +784,10 @@ def get_field_value( # noqa: C901, PLR0911, PLR0912
784784
785785 return cls .get_field_value (cls .__random__ .choice (children ), field_build_parameters , build_context )
786786
787+ provider_map = cls .get_provider_map ()
788+ if provider := (provider_map .get (field_meta .annotation ) or provider_map .get (unwrapped_annotation )):
789+ return provider ()
790+
787791 if BaseFactory .is_factory_type (annotation = unwrapped_annotation ):
788792 if not field_build_parameters and unwrapped_annotation in build_context ["seen_models" ]:
789793 return None if is_optional (field_meta .annotation ) else Null
@@ -844,10 +848,6 @@ def get_field_value( # noqa: C901, PLR0911, PLR0912
844848 build_context = build_context ,
845849 )
846850
847- provider_map = cls .get_provider_map ()
848- if provider := (provider_map .get (field_meta .annotation ) or provider_map .get (unwrapped_annotation )):
849- return provider ()
850-
851851 if is_type_var (unwrapped_annotation ):
852852 return create_random_string (cls .__random__ , min_length = 1 , max_length = 10 )
853853
@@ -913,6 +913,12 @@ def get_field_value_coverage( # noqa: C901,PLR0912
913913 field_meta = unwrapped_annotation_meta ,
914914 )
915915
916+ elif provider := (
917+ (provider_map := cls .get_provider_map ()).get (field_meta .annotation )
918+ or provider_map .get (unwrapped_annotation )
919+ ):
920+ yield CoverageContainerCallable (provider )
921+
916922 elif BaseFactory .is_factory_type (annotation = unwrapped_annotation ):
917923 yield CoverageContainer (
918924 cls ._get_or_create_factory (model = unwrapped_annotation ).coverage (
@@ -935,12 +941,6 @@ def get_field_value_coverage( # noqa: C901,PLR0912
935941
936942 yield handle_collection_type_coverage (child_meta , origin , cls , build_context = build_context )
937943
938- elif provider := (
939- (provider_map := cls .get_provider_map ()).get (field_meta .annotation )
940- or provider_map .get (unwrapped_annotation )
941- ):
942- yield CoverageContainerCallable (provider )
943-
944944 elif is_type_var (unwrapped_annotation ):
945945 yield create_random_string (cls .__random__ , min_length = 1 , max_length = 10 )
946946
0 commit comments