105105
106106class PydanticBuildContext (BaseBuildContext ):
107107 factory_use_construct : bool
108- by_name : NotRequired [bool ]
109108
110109
111110class PydanticConstraints (Constraints ):
@@ -529,7 +528,6 @@ def build(
529528 kwargs ["_build_context" ] = PydanticBuildContext (
530529 seen_models = set (),
531530 factory_use_construct = factory_use_construct ,
532- by_name = cls .__by_name__ ,
533531 )
534532
535533 processed_kwargs = cls .process_kwargs (** kwargs )
@@ -565,7 +563,7 @@ def _create_model(cls, _build_context: PydanticBuildContext, **kwargs: Any) -> T
565563 return cls .__model__ .model_construct (** kwargs )
566564
567565 # Use model_validate with by_name for Pydantic v2 models when requested
568- if _build_context . get ( "by_name" ) and _is_pydantic_v2_model (cls .__model__ ):
566+ if cls . __by_name__ and _is_pydantic_v2_model (cls .__model__ ):
569567 return cls .__model__ .model_validate (kwargs , by_name = True ) # type: ignore[return-value]
570568
571569 return cls .__model__ (** kwargs )
@@ -586,7 +584,6 @@ def coverage(cls, factory_use_construct: bool = False, **kwargs: Any) -> abc.Ite
586584 kwargs ["_build_context" ] = PydanticBuildContext (
587585 seen_models = set (),
588586 factory_use_construct = factory_use_construct ,
589- by_name = cls .__by_name__ ,
590587 )
591588
592589 for data in cls .process_kwargs_coverage (** kwargs ):
0 commit comments