Skip to content

Commit

Permalink
Merge pull request #2061 from kpopdev/patch-3
Browse files Browse the repository at this point in the history
Update types.py
  • Loading branch information
subzeroid authored Nov 26, 2024
2 parents 91dee6b + 459f4b5 commit e4258c2
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions instagrapi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@
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
video_url: Optional[HttpUrl] = None # for Video and IGTV
thumbnail_url: HttpUrl
media_type: int


class BioLink(TypesBaseModel):
link_id: str
url: str
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit e4258c2

Please sign in to comment.