108108
109109class PydanticBuildContext (BaseBuildContext ):
110110 factory_use_construct : bool
111- by_name : NotRequired [bool ]
112111
113112
114113class PydanticConstraints (Constraints ):
@@ -532,7 +531,6 @@ def build(
532531 kwargs ["_build_context" ] = PydanticBuildContext (
533532 seen_models = set (),
534533 factory_use_construct = factory_use_construct ,
535- by_name = cls .__by_name__ ,
536534 )
537535
538536 processed_kwargs = cls .process_kwargs (** kwargs )
@@ -568,7 +566,7 @@ def _create_model(cls, _build_context: PydanticBuildContext, **kwargs: Any) -> T
568566 return cls .__model__ .model_construct (** kwargs )
569567
570568 # Use model_validate with by_name for Pydantic v2 models when requested
571- if _build_context . get ( "by_name" ) and _is_pydantic_v2_model (cls .__model__ ):
569+ if cls . __by_name__ and _is_pydantic_v2_model (cls .__model__ ):
572570 return cls .__model__ .model_validate (kwargs , by_name = True ) # type: ignore[return-value]
573571
574572 return cls .__model__ (** kwargs )
@@ -589,7 +587,6 @@ def coverage(cls, factory_use_construct: bool = False, **kwargs: Any) -> abc.Ite
589587 kwargs ["_build_context" ] = PydanticBuildContext (
590588 seen_models = set (),
591589 factory_use_construct = factory_use_construct ,
592- by_name = cls .__by_name__ ,
593590 )
594591
595592 for data in cls .process_kwargs_coverage (** kwargs ):
0 commit comments