Skip to content

Commit

Permalink
Merge pull request subzeroid#1664 from jarrodnorwell/hotfix-keyerror-…
Browse files Browse the repository at this point in the history
…pydantic

Removed .lstrip() to fix KeyError and added model_config to fix Pydantic
  • Loading branch information
subzeroid authored Nov 29, 2023
2 parents dccce94 + f94765e commit 2afa90d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion instagrapi/mixins/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _send_public_request(
self.last_response_ts = time.time()

def public_a1_request(self, endpoint, data=None, params=None, headers=None):
url = self.PUBLIC_API_URL + endpoint.lstrip("/")
url = self.PUBLIC_API_URL + endpoint # (jarrodnorwell) fixed KeyError: 'data'
params = params or {}
params.update({"__a": 1, "__d": "dis"})

Expand Down
17 changes: 16 additions & 1 deletion instagrapi/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, FilePath, HttpUrl, ValidationError, validator
from pydantic import (
BaseModel,
ConfigDict,
FilePath,
HttpUrl,
ValidationError,
validator,
)


def validate_external_url(cls, v):
Expand All @@ -11,6 +18,10 @@ def validate_external_url(cls, v):


class Resource(BaseModel):
model_config = ConfigDict(
coerce_numbers_to_str=True
) # (jarrodnorwell) fixed pk issue

pk: str
video_url: Optional[HttpUrl] = None # for Video and IGTV
thumbnail_url: HttpUrl
Expand Down Expand Up @@ -73,6 +84,10 @@ class Account(BaseModel):


class UserShort(BaseModel):
model_config = ConfigDict(
coerce_numbers_to_str=True
) # (jarrodnorwell) fixed pk issue

pk: str
username: Optional[str] = None
full_name: Optional[str] = ""
Expand Down
2 changes: 1 addition & 1 deletion requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pillow==8.2.0
pip==21.0.1
proglog==0.1.9
pycryptodomex==3.9.9
pydantic==2.4.2
pydantic==2.5.2
PySocks==1.7.1
requests==2.25.1
setuptools==53.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requests==2.31.0
PySocks==1.7.1
pydantic==2.4.2
pydantic==2.5.2
moviepy==1.0.3
pycryptodomex==3.18.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
requirements = [
"requests<3.0,>=2.25.1",
"PySocks==1.7.1",
"pydantic==2.4.2",
"pydantic==2.5.2",
"pycryptodomex==3.18.0",
]
# requirements = [
Expand Down

0 comments on commit 2afa90d

Please sign in to comment.