2222
2323class Object (ActivityPubModel ):
2424 context : LDContext = Field (
25- default_factory = lambda : LDContext (
26- ["https://www.w3.org/ns/activitystreams" ]
27- ),
25+ default_factory = lambda : LDContext (["https://www.w3.org/ns/activitystreams" ]),
2826 kw_only = True ,
2927 alias = "@context" ,
3028 )
@@ -36,12 +34,10 @@ class Object(ActivityPubModel):
3634 url : Optional ["str | Link" ] = Field (default = None )
3735 published : Optional [str ] = Field (default = None )
3836 updated : Optional [str ] = Field (default = None )
39- attributed_to : Optional ["str | Actor | List[str | Actor]" ] = Field (
37+ attributed_to : Optional ["str | Actor | List[str | Actor]" ] = Field (default = None )
38+ audience : Optional ["str | Object | Dict[str, Any] | List[str | Object]" ] = Field (
4039 default = None
4140 )
42- audience : Optional ["str | Object | Dict[str, Any] | List[str | Object]" ] = (
43- Field (default = None )
44- )
4541 to : Optional [
4642 "str | Object | Dict[str, Any] | List[str | Object | Dict[str, Any]]"
4743 ] = Field (default = None )
@@ -64,9 +60,7 @@ class Object(ActivityPubModel):
6460 likes : Optional ["Collection" ] = Field (default = None )
6561 shares : Optional ["Collection" ] = Field (default = None )
6662 scope : "Optional[Object | Dict[str, Any]]" = Field (default = None )
67- tag : "List[Object | Hashtag | Emoji | Dict[str, Any]]" = Field (
68- default_factory = list
69- )
63+ tag : "List[Object | Hashtag | Emoji | Dict[str, Any]]" = Field (default_factory = list )
7064 attachment : "List[PropertyValue | Dict[str, Any] | Object | Link]" = Field (
7165 default_factory = list
7266 )
@@ -77,9 +71,7 @@ def _convert_field_to_model(cls, v: Any, info: ValidationInfo) -> Any:
7771
7872 if v is None :
7973 return None
80- parent_context = (
81- info .context .get ("ld_context" ) if info .context else None
82- )
74+ parent_context = info .context .get ("ld_context" ) if info .context else None
8375 return load (v , "raw" , parent_context = parent_context )
8476
8577 @field_validator ("url" , mode = "before" )
@@ -160,7 +152,8 @@ def validate_likes(cls, v: Any, info: ValidationInfo) -> Any:
160152 @field_validator ("shares" , mode = "before" )
161153 @classmethod
162154 def validate_shares (cls , v : Any , info : ValidationInfo ) -> Any :
163- return cls ._convert_field_to_model (v , info )
155+ return cls ._convert_field_to_model (v , info )
156+
164157 @field_validator ("scope" , mode = "before" )
165158 @classmethod
166159 def validate_scope (cls , v : Any , info : ValidationInfo ) -> Any :
0 commit comments