From 459f4b588c913137426d6c12bd2cc8be6b1778b1 Mon Sep 17 00:00:00 2001 From: Kyla Date: Fri, 15 Nov 2024 18:47:35 +0330 Subject: [PATCH] Update types.py Replaced @validator with @field_validator. Removed allow_reuse since it is no longer necessary. Ensured that comments are clear and grammatically correct. --- instagrapi/types.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/instagrapi/types.py b/instagrapi/types.py index ad0c6a30..453d1ca4 100644 --- a/instagrapi/types.py +++ b/instagrapi/types.py @@ -7,21 +7,18 @@ FilePath, HttpUrl, ValidationError, - validator, + field_validator, ) - class TypesBaseModel(BaseModel): model_config = ConfigDict( coerce_numbers_to_str=True ) # (jarrodnorwell) fixed city_id issue - def validate_external_url(cls, v): if v is None or (v.startswith("http") and "://" in v) or isinstance(v, str): return v - raise ValidationError("external_url must been URL or string") - + raise ValidationError("external_url must be a URL or string") # Corrected 'been' to 'be' class Resource(TypesBaseModel): pk: str @@ -29,7 +26,6 @@ class Resource(TypesBaseModel): thumbnail_url: HttpUrl media_type: int - class BioLink(TypesBaseModel): link_id: str url: str @@ -39,7 +35,6 @@ class BioLink(TypesBaseModel): is_pinned: Optional[bool] = None open_external_url_with_in_app_browser: Optional[bool] = None - class Broadcast(TypesBaseModel): title: str thread_igid: str @@ -50,10 +45,9 @@ class Broadcast(TypesBaseModel): group_image_background_uri: str thread_subtype: int number_of_members: int - creator_igid: str | None + creator_igid: Optional[str] = None # Changed from str | None to Optional[str] creator_username: str - class User(TypesBaseModel): pk: str username: str @@ -91,8 +85,7 @@ class User(TypesBaseModel): instagram_location_id: Optional[str] = None interop_messaging_user_fbid: Optional[str] = None - _external_url = validator("external_url", allow_reuse=True)(validate_external_url) - + _external_url = field_validator("external_url")(validate_external_url) # Updated to use field_validator class Account(TypesBaseModel): pk: str @@ -109,8 +102,7 @@ class Account(TypesBaseModel): gender: Optional[int] = None email: Optional[str] = None - _external_url = validator("external_url", allow_reuse=True)(validate_external_url) - + _external_url = field_validator("external_url")(validate_external_url) # Updated to use field_validator class UserShort(TypesBaseModel): def __hash__(self):