@@ -573,13 +573,6 @@ def _internal_class_schema(
573573 return cast (Type [marshmallow .Schema ], schema_class )
574574
575575
576- def _field_by_type (typ : Union [type , Any ]) -> Optional [Type [marshmallow .fields .Field ]]:
577- # FIXME: remove this function
578- schema_ctx = _schema_ctx_stack .top
579- type_mapping = schema_ctx .get_type_mapping (include_marshmallow_default = True )
580- return type_mapping .get (typ )
581-
582-
583576def _field_by_supertype (
584577 typ : Type ,
585578 default : Any ,
@@ -787,9 +780,12 @@ def _field_for_schema(
787780 # Generic types specified without type arguments
788781 typ = _generic_type_add_any (typ )
789782
783+ schema_ctx = _schema_ctx_stack .top
784+
790785 # Base types
791- field = _field_by_type (typ )
792- if field :
786+ type_mapping = schema_ctx .get_type_mapping (include_marshmallow_default = True )
787+ field = type_mapping .get (typ )
788+ if field is not None :
793789 return field (** metadata )
794790
795791 if typ is Any :
@@ -874,12 +870,13 @@ def _field_for_schema(
874870 # Nested dataclasses
875871 forward_reference = getattr (typ , "__forward_arg__" , None )
876872
877- base_schema = _schema_ctx_stack .top .base_schema
878873 nested = (
879874 nested_schema
880875 or forward_reference
881- or _schema_ctx_stack .top .seen_classes .get (typ )
882- or _internal_class_schema (typ , base_schema ) # type: ignore[arg-type] # FIXME
876+ or schema_ctx .seen_classes .get (typ )
877+ or _internal_class_schema (
878+ typ , schema_ctx .base_schema # type: ignore[arg-type] # FIXME
879+ )
883880 )
884881
885882 return marshmallow .fields .Nested (nested , ** metadata )
0 commit comments