Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alp Ogut
mastodon
Commits
220e881a
Commit
220e881a
authored
2 years ago
by
Aziz Berkay Yesilyurt
Browse files
Options
Download
Plain Diff
Merge branch 'aziz/linter' into 'dev'
fix linter See merge request
memri/plugins/twitter-v2!29
parents
abf46343
9ab71fde
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.pre-commit-config.yaml
+1
-0
.pre-commit-config.yaml
twitter_v2/plugin.py
+1
-2
twitter_v2/plugin.py
twitter_v2/schema.py
+0
-3
twitter_v2/schema.py
twitter_v2/tweepy_util.py
+7
-7
twitter_v2/tweepy_util.py
with
9 additions
and
12 deletions
+9
-12
.pre-commit-config.yaml
+
1
-
0
View file @
220e881a
...
...
@@ -20,6 +20,7 @@ repos:
hooks
:
-
id
:
flake8
args
:
[
"
--max-line-length"
,
"
88"
]
# - repo: local
# hooks:
# - id: mypy
...
...
This diff is collapsed.
Click to expand it.
twitter_v2/plugin.py
+
1
-
2
View file @
220e881a
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
twitter_v2/schema.py
+
0
-
3
View file @
220e881a
...
...
@@ -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"
],
...
...
This diff is collapsed.
Click to expand it.
twitter_v2/tweepy_util.py
+
7
-
7
View file @
220e881a
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment