105105
106106class PydanticBuildContext (BaseBuildContext ):
107107 factory_use_construct : bool
108- by_name : NotRequired [bool ]
109108
110109
111110class PydanticConstraints (Constraints ):
@@ -525,7 +524,6 @@ def build(
525524 kwargs ["_build_context" ] = PydanticBuildContext (
526525 seen_models = set (),
527526 factory_use_construct = factory_use_construct ,
528- by_name = cls .__by_name__ ,
529527 )
530528
531529 processed_kwargs = cls .process_kwargs (** kwargs )
@@ -561,7 +559,7 @@ def _create_model(cls, _build_context: PydanticBuildContext, **kwargs: Any) -> T
561559 return cls .__model__ .model_construct (** kwargs )
562560
563561 # Use model_validate with by_name for Pydantic v2 models when requested
564- if _build_context . get ( "by_name" ) and _is_pydantic_v2_model (cls .__model__ ):
562+ if cls . __by_name__ and _is_pydantic_v2_model (cls .__model__ ):
565563 return cls .__model__ .model_validate (kwargs , by_name = True ) # type: ignore[return-value]
566564
567565 return cls .__model__ (** kwargs )
@@ -582,7 +580,6 @@ def coverage(cls, factory_use_construct: bool = False, **kwargs: Any) -> abc.Ite
582580 kwargs ["_build_context" ] = PydanticBuildContext (
583581 seen_models = set (),
584582 factory_use_construct = factory_use_construct ,
585- by_name = cls .__by_name__ ,
586583 )
587584
588585 for data in cls .process_kwargs_coverage (** kwargs ):
0 commit comments