Fix black version

This commit is contained in:
Mads Marquart
2019-12-11 16:11:54 +01:00
parent b8f83610e7
commit e348425204
4 changed files with 21 additions and 19 deletions

View File

@@ -198,7 +198,7 @@ class Client:
def _forced_fetch(self, thread_id, mid): def _forced_fetch(self, thread_id, mid):
params = {"thread_and_message_id": {"thread_id": thread_id, "message_id": mid}} params = {"thread_and_message_id": {"thread_id": thread_id, "message_id": mid}}
j, = self.graphql_requests(_graphql.from_doc_id("1768656253222505", params)) (j,) = self.graphql_requests(_graphql.from_doc_id("1768656253222505", params))
return j return j
def fetch_threads(self, thread_location, before=None, after=None, limit=None): def fetch_threads(self, thread_location, before=None, after=None, limit=None):
@@ -323,7 +323,7 @@ class Client:
FBchatException: If request failed FBchatException: If request failed
""" """
params = {"search": name, "limit": limit} params = {"search": name, "limit": limit}
j, = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_USER, params)) (j,) = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_USER, params))
return [User._from_graphql(node) for node in j[name]["users"]["nodes"]] return [User._from_graphql(node) for node in j[name]["users"]["nodes"]]
@@ -340,7 +340,7 @@ class Client:
FBchatException: If request failed FBchatException: If request failed
""" """
params = {"search": name, "limit": limit} params = {"search": name, "limit": limit}
j, = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_PAGE, params)) (j,) = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_PAGE, params))
return [Page._from_graphql(node) for node in j[name]["pages"]["nodes"]] return [Page._from_graphql(node) for node in j[name]["pages"]["nodes"]]
@@ -358,7 +358,7 @@ class Client:
FBchatException: If request failed FBchatException: If request failed
""" """
params = {"search": name, "limit": limit} params = {"search": name, "limit": limit}
j, = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_GROUP, params)) (j,) = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_GROUP, params))
return [Group._from_graphql(node) for node in j["viewer"]["groups"]["nodes"]] return [Group._from_graphql(node) for node in j["viewer"]["groups"]["nodes"]]
@@ -376,7 +376,9 @@ class Client:
FBchatException: If request failed FBchatException: If request failed
""" """
params = {"search": name, "limit": limit} params = {"search": name, "limit": limit}
j, = self.graphql_requests(_graphql.from_query(_graphql.SEARCH_THREAD, params)) (j,) = self.graphql_requests(
_graphql.from_query(_graphql.SEARCH_THREAD, params)
)
rtn = [] rtn = []
for node in j[name]["threads"]["nodes"]: for node in j[name]["threads"]["nodes"]:
@@ -679,7 +681,7 @@ class Client:
"load_read_receipts": True, "load_read_receipts": True,
"before": _util.datetime_to_millis(before) if before else None, "before": _util.datetime_to_millis(before) if before else None,
} }
j, = self.graphql_requests(_graphql.from_doc_id("1860982147341344", params)) (j,) = self.graphql_requests(_graphql.from_doc_id("1860982147341344", params))
if j.get("message_thread") is None: if j.get("message_thread") is None:
raise FBchatException("Could not fetch thread {}: {}".format(thread_id, j)) raise FBchatException("Could not fetch thread {}: {}".format(thread_id, j))
@@ -733,7 +735,7 @@ class Client:
"includeDeliveryReceipts": True, "includeDeliveryReceipts": True,
"includeSeqID": False, "includeSeqID": False,
} }
j, = self.graphql_requests(_graphql.from_doc_id("1349387578499440", params)) (j,) = self.graphql_requests(_graphql.from_doc_id("1349387578499440", params))
rtn = [] rtn = []
for node in j["viewer"]["message_threads"]["nodes"]: for node in j["viewer"]["message_threads"]["nodes"]:
@@ -853,7 +855,7 @@ class Client:
return Plan._from_fetch(j) return Plan._from_fetch(j)
def _get_private_data(self): def _get_private_data(self):
j, = self.graphql_requests(_graphql.from_doc_id("1868889766468115", {})) (j,) = self.graphql_requests(_graphql.from_doc_id("1868889766468115", {}))
return j["viewer"] return j["viewer"]
def get_phone_numbers(self): def get_phone_numbers(self):
@@ -903,7 +905,7 @@ class Client:
""" """
data = {"id": thread_id, "first": 48} data = {"id": thread_id, "first": 48}
thread_id = str(thread_id) thread_id = str(thread_id)
j, = self.graphql_requests(_graphql.from_query_id("515216185516880", data)) (j,) = self.graphql_requests(_graphql.from_query_id("515216185516880", data))
while True: while True:
try: try:
i = j[thread_id]["message_shared_media"]["edges"][0] i = j[thread_id]["message_shared_media"]["edges"][0]
@@ -914,7 +916,7 @@ class Client:
data["after"] = j[thread_id]["message_shared_media"][ data["after"] = j[thread_id]["message_shared_media"][
"page_info" "page_info"
].get("end_cursor") ].get("end_cursor")
j, = self.graphql_requests( (j,) = self.graphql_requests(
_graphql.from_query_id("515216185516880", data) _graphql.from_query_id("515216185516880", data)
) )
continue continue
@@ -1369,7 +1371,7 @@ class Client:
"response": "ACCEPT" if approve else "DENY", "response": "ACCEPT" if approve else "DENY",
"surface": "ADMIN_MODEL_APPROVAL_CENTER", "surface": "ADMIN_MODEL_APPROVAL_CENTER",
} }
j, = self.graphql_requests( (j,) = self.graphql_requests(
_graphql.from_doc_id("1574519202665847", {"data": data}) _graphql.from_doc_id("1574519202665847", {"data": data})
) )
@@ -1422,7 +1424,7 @@ class Client:
Raises: Raises:
FBchatException: If request failed FBchatException: If request failed
""" """
(image_id, mimetype), = self._upload(_util.get_files_from_urls([image_url])) ((image_id, mimetype),) = self._upload(_util.get_files_from_urls([image_url]))
return self._change_group_image(image_id, thread_id) return self._change_group_image(image_id, thread_id)
def change_group_image_local(self, image_path, thread_id=None): def change_group_image_local(self, image_path, thread_id=None):
@@ -1436,7 +1438,7 @@ class Client:
FBchatException: If request failed FBchatException: If request failed
""" """
with _util.get_files_from_paths([image_path]) as files: with _util.get_files_from_paths([image_path]) as files:
(image_id, mimetype), = self._upload(files) ((image_id, mimetype),) = self._upload(files)
return self._change_group_image(image_id, thread_id) return self._change_group_image(image_id, thread_id)

View File

@@ -25,7 +25,7 @@ def test_fetch_threads(client1):
@pytest.mark.parametrize("emoji, emoji_size", EMOJI_LIST) @pytest.mark.parametrize("emoji, emoji_size", EMOJI_LIST)
def test_fetch_message_emoji(client, emoji, emoji_size): def test_fetch_message_emoji(client, emoji, emoji_size):
mid = client.send_emoji(emoji, emoji_size) mid = client.send_emoji(emoji, emoji_size)
message, = client.fetch_thread_messages(limit=1) (message,) = client.fetch_thread_messages(limit=1)
assert subset( assert subset(
vars(message), uid=mid, author=client.uid, text=emoji, emoji_size=emoji_size vars(message), uid=mid, author=client.uid, text=emoji, emoji_size=emoji_size
@@ -44,7 +44,7 @@ def test_fetch_message_info_emoji(client, thread, emoji, emoji_size):
def test_fetch_message_mentions(client, thread, message_with_mentions): def test_fetch_message_mentions(client, thread, message_with_mentions):
mid = client.send(message_with_mentions) mid = client.send(message_with_mentions)
message, = client.fetch_thread_messages(limit=1) (message,) = client.fetch_thread_messages(limit=1)
assert subset( assert subset(
vars(message), uid=mid, author=client.uid, text=message_with_mentions.text vars(message), uid=mid, author=client.uid, text=message_with_mentions.text
@@ -69,7 +69,7 @@ def test_fetch_message_info_mentions(client, thread, message_with_mentions):
@pytest.mark.parametrize("sticker", STICKER_LIST) @pytest.mark.parametrize("sticker", STICKER_LIST)
def test_fetch_message_sticker(client, sticker): def test_fetch_message_sticker(client, sticker):
mid = client.send(Message(sticker=sticker)) mid = client.send(Message(sticker=sticker))
message, = client.fetch_thread_messages(limit=1) (message,) = client.fetch_thread_messages(limit=1)
assert subset(vars(message), uid=mid, author=client.uid) assert subset(vars(message), uid=mid, author=client.uid)
assert subset(vars(message.sticker), uid=sticker.uid) assert subset(vars(message.sticker), uid=sticker.uid)
@@ -96,6 +96,6 @@ def test_fetch_image_url(client):
client.send_local_files( client.send_local_files(
[path.join(path.dirname(__file__), "resources", "image.png")] [path.join(path.dirname(__file__), "resources", "image.png")]
) )
message, = client.fetch_thread_messages(limit=1) (message,) = client.fetch_thread_messages(limit=1)
assert client.fetch_image_url(message.attachments[0].uid) assert client.fetch_image_url(message.attachments[0].uid)

View File

@@ -17,5 +17,5 @@ def test_delete_messages(client):
mid1 = client.send(Message(text=text1)) mid1 = client.send(Message(text=text1))
mid2 = client.send(Message(text=text2)) mid2 = client.send(Message(text=text2))
client.delete_messages(mid2) client.delete_messages(mid2)
message, = client.fetch_thread_messages(limit=1) (message,) = client.fetch_thread_messages(limit=1)
assert subset(vars(message), uid=mid1, author=client.uid, text=text1) assert subset(vars(message), uid=mid1, author=client.uid, text=text1)

View File

@@ -61,7 +61,7 @@ def test_create_poll(client1, group, catch_event, poll_data):
for recv_option in event[ for recv_option in event[
"poll" "poll"
].options: # The recieved options may not be the full list ].options: # The recieved options may not be the full list
old_option, = list(filter(lambda o: o.text == recv_option.text, poll.options)) (old_option,) = list(filter(lambda o: o.text == recv_option.text, poll.options))
voters = [client1.uid] if old_option.vote else [] voters = [client1.uid] if old_option.vote else []
assert subset( assert subset(
vars(recv_option), voters=voters, votes_count=len(voters), vote=False vars(recv_option), voters=voters, votes_count=len(voters), vote=False