From c4f2272005ffe1a5918a66b25348c50256c98c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 6 Feb 2024 15:12:53 +0900 Subject: [PATCH 1/6] update vscode settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- twitter_openapi_python/.vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/twitter_openapi_python/.vscode/launch.json b/twitter_openapi_python/.vscode/launch.json index 1c79cfac..c53552ce 100644 --- a/twitter_openapi_python/.vscode/launch.json +++ b/twitter_openapi_python/.vscode/launch.json @@ -3,11 +3,11 @@ "configurations": [ { "name": "Python: Current File", - "type": "python", + "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal", "justMyCode": false } ] -} +} \ No newline at end of file From c71e83dcb08a4abe59ad04e556a50d3b2498c86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 6 Feb 2024 15:51:01 +0900 Subject: [PATCH 2/6] update pydantic v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- twitter_openapi_python/pyproject.toml | 4 ++-- twitter_openapi_python/requirements.txt | Bin 130 -> 114 bytes twitter_openapi_python/setup.py | 2 +- .../twitter_openapi_python/models/__init__.py | 2 +- .../twitter_openapi_python/models/base.py | 13 +++++-------- .../twitter_openapi_python/models/response.py | 4 ++-- .../twitter_openapi_python/models/timeline.py | 4 ++-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/twitter_openapi_python/pyproject.toml b/twitter_openapi_python/pyproject.toml index 25980652..38b54bd1 100644 --- a/twitter_openapi_python/pyproject.toml +++ b/twitter_openapi_python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "twitter_openapi_python" -version = "0.0.12" +version = "0.0.13" description = "Twitter OpenAPI" authors = ["fa0311 "] license = "proprietary" # or "AGPL-3.0-only" @@ -12,7 +12,7 @@ include = ["twitter_openapi_python/py.typed"] [tool.poetry.dependencies] python = "^3.7" -pydantic = "^1.10.5, <2" +pydantic = ">=2.6" twitter-openapi-python-generated = "0.0.7" diff --git a/twitter_openapi_python/requirements.txt b/twitter_openapi_python/requirements.txt index bfeaf913e4f77262edcc245ea232a0963c33f8c3..76367ab53692da4a9680c63386a1ce4687610289 100644 GIT binary patch delta 17 YcmZo-ESez2YQ&(&U^Y=dkjat(03<2{hX4Qo delta 33 lcmXSFVw@l)YRI6+V8~zqBuyD~7!(+6fY@lFd?1qr0{~q>1nmF- diff --git a/twitter_openapi_python/setup.py b/twitter_openapi_python/setup.py index 3cd43337..951ef98c 100644 --- a/twitter_openapi_python/setup.py +++ b/twitter_openapi_python/setup.py @@ -7,7 +7,7 @@ PYTHON_REQUIRES = ">=3.7" REQUIRES = [ "twitter_openapi_python_generated == 0.0.6", - "pydantic >= 1.10.5, < 2", + "pydantic >= 2.6", ] setup( diff --git a/twitter_openapi_python/twitter_openapi_python/models/__init__.py b/twitter_openapi_python/twitter_openapi_python/models/__init__.py index 129ba6cc..76adcf0a 100644 --- a/twitter_openapi_python/twitter_openapi_python/models/__init__.py +++ b/twitter_openapi_python/twitter_openapi_python/models/__init__.py @@ -3,7 +3,7 @@ # flake8: noqa -from twitter_openapi_python.models.base import BaseModel, GenericModel +from twitter_openapi_python.models.base import BaseModel from twitter_openapi_python.models.header import ApiUtilsHeader from twitter_openapi_python.models.initial_state import ( InitialStateApiUtilsRaw, diff --git a/twitter_openapi_python/twitter_openapi_python/models/base.py b/twitter_openapi_python/twitter_openapi_python/models/base.py index e685b092..6b70e287 100644 --- a/twitter_openapi_python/twitter_openapi_python/models/base.py +++ b/twitter_openapi_python/twitter_openapi_python/models/base.py @@ -1,12 +1,9 @@ -from pydantic import BaseModel as PydanticBaseModel -from pydantic.generics import GenericModel as PydanticGenericModel +from typing import TypeVar +from pydantic import BaseModel as PydanticBaseModel -class BaseModel(PydanticBaseModel): - class Config: - arbitrary_types_allowed = True +T = TypeVar("T") -class GenericModel(PydanticGenericModel): - class Config: - arbitrary_types_allowed = True +class BaseModel(PydanticBaseModel): + model_config = {"arbitrary_types_allowed": True} diff --git a/twitter_openapi_python/twitter_openapi_python/models/response.py b/twitter_openapi_python/twitter_openapi_python/models/response.py index e79d8d7e..b934ffa0 100644 --- a/twitter_openapi_python/twitter_openapi_python/models/response.py +++ b/twitter_openapi_python/twitter_openapi_python/models/response.py @@ -3,7 +3,7 @@ import twitter_openapi_python_generated as twitter from pydantic import Field -from twitter_openapi_python.models import ApiUtilsHeader, BaseModel, GenericModel +from twitter_openapi_python.models import ApiUtilsHeader, BaseModel T1 = TypeVar("T1") T2 = TypeVar("T2") @@ -13,7 +13,7 @@ class TwitterApiUtilsRaw(BaseModel): response: twitter.ApiResponse = Field() -class TwitterApiUtilsResponse(GenericModel, Generic[T1]): +class TwitterApiUtilsResponse(BaseModel, Generic[T1]): raw: TwitterApiUtilsRaw = Field() data: T1 = Field() header: ApiUtilsHeader = Field() diff --git a/twitter_openapi_python/twitter_openapi_python/models/timeline.py b/twitter_openapi_python/twitter_openapi_python/models/timeline.py index 83fa26ee..9415b56a 100644 --- a/twitter_openapi_python/twitter_openapi_python/models/timeline.py +++ b/twitter_openapi_python/twitter_openapi_python/models/timeline.py @@ -4,7 +4,7 @@ import twitter_openapi_python_generated.models as models from pydantic import Field -from twitter_openapi_python.models import BaseModel, GenericModel +from twitter_openapi_python.models import BaseModel T = TypeVar("T") @@ -34,7 +34,7 @@ class UserApiUtilsData(BaseModel): user: models.User = Field() -class TimelineApiUtilsResponse(GenericModel, Generic[T]): +class TimelineApiUtilsResponse(BaseModel, Generic[T]): raw: ApiUtilsRaw = Field() cursor: CursorApiUtilsResponse = Field() data: List[T] = Field(default_factory=list) From 61358995ca99766eb167dd0bf67d81fe39324e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 6 Feb 2024 15:58:56 +0900 Subject: [PATCH 3/6] update version 0.0.13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- twitter_openapi_python/pyproject.toml | 2 +- twitter_openapi_python/setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/twitter_openapi_python/pyproject.toml b/twitter_openapi_python/pyproject.toml index 38b54bd1..53cf0826 100644 --- a/twitter_openapi_python/pyproject.toml +++ b/twitter_openapi_python/pyproject.toml @@ -14,7 +14,7 @@ include = ["twitter_openapi_python/py.typed"] python = "^3.7" pydantic = ">=2.6" -twitter-openapi-python-generated = "0.0.7" +twitter-openapi-python-generated = "0.0.9" [tool.poetry.dev-dependencies] diff --git a/twitter_openapi_python/setup.py b/twitter_openapi_python/setup.py index 951ef98c..cd5ff47c 100644 --- a/twitter_openapi_python/setup.py +++ b/twitter_openapi_python/setup.py @@ -3,10 +3,10 @@ from setuptools import find_packages, setup NAME = "twitter_openapi_python" -VERSION = "0.0.12" +VERSION = "0.0.13" PYTHON_REQUIRES = ">=3.7" REQUIRES = [ - "twitter_openapi_python_generated == 0.0.6", + "twitter_openapi_python_generated == 0.0.9", "pydantic >= 2.6", ] From 4bacacd961e081479be930beb6a031ca9bdc560a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 6 Feb 2024 16:01:48 +0900 Subject: [PATCH 4/6] update sample for example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- example/requirements.txt | Bin 848 -> 848 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/example/requirements.txt b/example/requirements.txt index b928afb60ca49cf113b97a4be96197f92b5c0cae..052f6035416785d2c6fc148a428384c839a0f048 100644 GIT binary patch delta 19 bcmcb>c7bg}3KOI8c7bg}3KOHz Date: Tue, 6 Feb 2024 16:01:56 +0900 Subject: [PATCH 5/6] update formatter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- example/.vscode/extensions.json | 8 ++++++++ example/.vscode/launch.json | 4 ++-- example/.vscode/settings.json | 9 ++++++--- example/sample/download_media.py | 16 ++++++++-------- example/sample/login.py | 4 ++-- example/sample/tweet.py | 4 ++-- example/sample/tweet_media.py | 5 +---- example/sample/user.py | 11 +++++------ 8 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 example/.vscode/extensions.json diff --git a/example/.vscode/extensions.json b/example/.vscode/extensions.json new file mode 100644 index 00000000..724dfe72 --- /dev/null +++ b/example/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "ms-python.vscode-pylance", + "ms-python.python", + "ms-python.debugpy", + "charliermarsh.ruff" + ] +} \ No newline at end of file diff --git a/example/.vscode/launch.json b/example/.vscode/launch.json index 1c79cfac..c53552ce 100644 --- a/example/.vscode/launch.json +++ b/example/.vscode/launch.json @@ -3,11 +3,11 @@ "configurations": [ { "name": "Python: Current File", - "type": "python", + "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal", "justMyCode": false } ] -} +} \ No newline at end of file diff --git a/example/.vscode/settings.json b/example/.vscode/settings.json index 22a7db29..3f95366f 100644 --- a/example/.vscode/settings.json +++ b/example/.vscode/settings.json @@ -1,5 +1,8 @@ { - "flake8.args": [], "editor.unicodeHighlight.ambiguousCharacters": false, - "python.analysis.typeCheckingMode": "basic" -} + "python.analysis.typeCheckingMode": "basic", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit", + "source.fixAll": "explicit" + }, +} \ No newline at end of file diff --git a/example/sample/download_media.py b/example/sample/download_media.py index 91785875..ebb935ba 100644 --- a/example/sample/download_media.py +++ b/example/sample/download_media.py @@ -1,15 +1,15 @@ +import os +import urllib.request +from pathlib import Path +from typing import Optional + +import login as login from twitter_openapi_python import ( - TwitterOpenapiPython, - TimelineTimelineCursor, MediaExtended, + TimelineTimelineCursor, TweetApiUtilsData, + TwitterOpenapiPython, ) -from typing import Optional -import login as login -import urllib.request -import os -from pathlib import Path - cookies_dict = login.login().get_cookies().get_dict() 𝕏 = TwitterOpenapiPython().get_client_from_cookies(cookies=cookies_dict) diff --git a/example/sample/login.py b/example/sample/login.py index 4d8ddd87..a3fee112 100644 --- a/example/sample/login.py +++ b/example/sample/login.py @@ -1,8 +1,8 @@ import json - from pathlib import Path -from tweepy_authlib import CookieSessionUserHandler + from requests.cookies import RequestsCookieJar +from tweepy_authlib import CookieSessionUserHandler def login(): diff --git a/example/sample/tweet.py b/example/sample/tweet.py index 55cc326a..284771c1 100644 --- a/example/sample/tweet.py +++ b/example/sample/tweet.py @@ -1,7 +1,7 @@ import datetime -from twitter_openapi_python import TwitterOpenapiPython -import login as login +import login as login +from twitter_openapi_python import TwitterOpenapiPython cookies_dict = login.login().get_cookies().get_dict() 𝕏 = TwitterOpenapiPython().get_client_from_cookies(cookies=cookies_dict) diff --git a/example/sample/tweet_media.py b/example/sample/tweet_media.py index f79caa58..9f892fca 100644 --- a/example/sample/tweet_media.py +++ b/example/sample/tweet_media.py @@ -1,9 +1,6 @@ -from twitter_openapi_python import TwitterOpenapiPython - - import login as login import tweepy - +from twitter_openapi_python import TwitterOpenapiPython auth_handler = login.login() cookies_dict = auth_handler.get_cookies().get_dict() diff --git a/example/sample/user.py b/example/sample/user.py index 93836f7a..4726eebf 100644 --- a/example/sample/user.py +++ b/example/sample/user.py @@ -1,11 +1,10 @@ -from twitter_openapi_python import TwitterOpenapiPython -import login as login - - -import urllib.request -from urllib.parse import urlparse import os +import urllib.request from pathlib import Path +from urllib.parse import urlparse + +import login as login +from twitter_openapi_python import TwitterOpenapiPython cookies_dict = login.login().get_cookies().get_dict() 𝕏 = TwitterOpenapiPython().get_client_from_cookies(cookies=cookies_dict) From 7dec03dbb73ee4449a5178642bf0495ef3401f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 6 Feb 2024 16:03:05 +0900 Subject: [PATCH 6/6] update requirements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- example/requirements.txt | Bin 848 -> 844 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/example/requirements.txt b/example/requirements.txt index 052f6035416785d2c6fc148a428384c839a0f048..caab155a55101c95e1f5c47eb60c4f19fd3af156 100644 GIT binary patch delta 22 ccmcb>c7|;O6C