Commit 220e881a authored by Aziz Berkay Yesilyurt's avatar Aziz Berkay Yesilyurt
Browse files

Merge branch 'aziz/linter' into 'dev'

fix linter

See merge request memri/plugins/twitter-v2!29
parents abf46343 9ab71fde
Showing with 9 additions and 12 deletions
+9 -12
......@@ -20,6 +20,7 @@ repos:
hooks:
- id: flake8
args: ["--max-line-length", "88"]
# - repo: local
# hooks:
# - id: mypy
......
......@@ -241,7 +241,7 @@ class TwitterPlugin(PluginBase):
ref_tweet = tweepy_tweet.referenced_tweets[0]
ref_tweet_id = str(ref_tweet.id)
if ref_tweet_id not in self.tweets_in_pod:
ref_full_tweepy_tweet = self.tweepy_producer.get_tweet(id=ref_tweet.id)
ref_full_tweepy_tweet = self.tweepy_producer.get_tweet(id_=ref_tweet.id)
if not ref_full_tweepy_tweet:
logger.warning(
f"Could not get referenced tweet with id: {ref_tweet.id}"
......@@ -461,7 +461,6 @@ class TwitterPlugin(PluginBase):
if conversation_id is None and tweet_item_id is None:
raise ValueError("Either conversation_id or tweet_item_id must be provided")
# tweet_item: Optional[Tweet] = None
if tweet_item_id:
tweet_item = self.client.get(tweet_item_id)
if tweet_item is None:
......
......@@ -30,7 +30,6 @@ class Account(HashableItem, schema.Account):
if user.public_metrics is None:
return cls(
externalId=user.id,
# service=SERVICE_NAME,
displayName=user.name,
handle=user.username,
description=user.description,
......@@ -38,7 +37,6 @@ class Account(HashableItem, schema.Account):
)
return cls(
externalId=user.id,
# service=SERVICE_NAME,
displayName=user.name,
handle=user.username,
description=user.description,
......@@ -83,7 +81,6 @@ class Tweet(HashableItem, schema.Tweet):
externalId=tweet.id,
message=tweet.text,
conversationId=tweet.conversation_id,
# service=SERVICE_NAME,
tweetType=tweet_type, # type: ignore
postDate=tweet.created_at,
retweetCount=tweet.public_metrics["retweet_count"],
......
......@@ -80,22 +80,22 @@ class TweepyProducer:
self.users_cache: Dict[str, tweepy.User] = dict()
self.media_cache: Dict[str, tweepy.Media] = dict()
def get_tweet(self, *, id: str) -> Optional[tweepy.Tweet]:
id = str(id)
if id not in self.tweets_cache:
def get_tweet(self, *, id_: str) -> Optional[tweepy.Tweet]:
id_ = str(id_)
if id_ not in self.tweets_cache:
# return None
try:
self.tweets_cache[id] = self._client.get_tweet(
id,
self.tweets_cache[id_] = self._client.get_tweet(
id_,
tweet_fields=TWEET_FIELDS,
expansions=EXPANSIONS,
user_fields=USER_FIELDS,
media_fields=MEDIA_FIELDS,
).data
except ConnectionError:
logger.error(f"Cannot get tweet {id}")
logger.error(f"Cannot get tweet {id_}")
return None
return self.tweets_cache[id]
return self.tweets_cache[id_]
def get_user(self, *, id: str) -> tweepy.User:
if id not in self.users_cache:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment