@@ -43,25 +43,25 @@ class A2ABaseModel(BaseModel):
4343 # The type hint is now corrected to be `ClassVar[<optional_type>]`.
4444 _alias_to_field_name_map : ClassVar [dict [str , str ] | None ] = None
4545
46- def __setattr__ (self , name : str , value : Any ):
46+ def __setattr__ (self , name : str , value : Any ) -> None :
4747 """Allow setting attributes via their camelCase alias.
4848
4949 This is overridden to provide backward compatibility for code that
5050 sets model fields using aliases after initialization.
5151 """
5252 # Build the alias-to-name mapping on first use and cache it.
53- if self .__class__ ._alias_to_field_name_map is None :
53+ if self .__class__ ._alias_to_field_name_map is None : # noqa: SLF001
5454 # Using a lock or other mechanism could make this more thread-safe
5555 # for highly concurrent applications, but this is fine for most cases.
56- self .__class__ ._alias_to_field_name_map = {
56+ self .__class__ ._alias_to_field_name_map = { # noqa: SLF001
5757 field .alias : field_name
5858 for field_name , field in self .model_fields .items ()
5959 if field .alias is not None
6060 }
6161
6262 # If the attribute name is a known alias, redirect the assignment
6363 # to the actual (snake_case) field name.
64- field_name = self .__class__ ._alias_to_field_name_map .get (name )
64+ field_name = self .__class__ ._alias_to_field_name_map .get (name ) # noqa: SLF001
6565 if field_name :
6666 # Use the actual field name for the assignment
6767 super ().__setattr__ (field_name , value )
0 commit comments