Skip to content

Commit

Permalink
Upgrade validation tool versions
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Oct 4, 2023
1 parent ed5f010 commit d8a593c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
pip install -U pip
pip install -e ".[testing]"
# We manually upgrade it to make the builds stable
pip install "flake8==4.0.1"
pip install "flake8==6.1.0"
- name: Run flake8
run: |
flake8 slack_discovery_sdk/
2 changes: 1 addition & 1 deletion .github/workflows/pytype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
pip install -U pip
pip install -e ".[testing]"
# As pytype can change its behavior in newer versions, we manually upgrade it
pip install "pytype==2023.05.24"
pip install "pytype==2023.9.27"
- name: Run pytype
run: |
pytype slack_discovery_sdk/
1 change: 0 additions & 1 deletion slack_discovery_sdk/examples/DLP_call_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
)

for message in channel_conversation["messages"]:

# Step 3 - check each message and see if it contains a credit card number. If it does, tombstone the message.
# A valid credit card for our logic is something like the following: '5122-2368-7954-3214'
# Please note this is just example logic, to help you understand how to use the Discovery APIs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
list_of_conversations = client.discovery_user_conversations(user=user_id, limit=500)

for conversation in list_of_conversations["channels"]:

channel_id = conversation["id"]
team_id = conversation["team_id"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
list_of_conversations = client.discovery_user_conversations(user=user_id, limit=500)

for conversation in list_of_conversations["channels"]:

channel_id = conversation["id"]
team_id = conversation["team_id"]

Expand Down
17 changes: 11 additions & 6 deletions slack_discovery_sdk/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@


_LATEST_OFFSET_APIS = [
'discovery.conversations.history',
'discovery.conversations.edits',
'discovery.conversations.renames',
'discovery.conversations.reactions',
'discovery.conversations.recent',
"discovery.conversations.history",
"discovery.conversations.edits",
"discovery.conversations.renames",
"discovery.conversations.reactions",
"discovery.conversations.recent",
]


Expand Down Expand Up @@ -129,7 +129,12 @@ def __next__(self):
# offset for https://api.slack.com/enterprise/discovery/methods#users_list etc.
params.update({"offset": self.body.get("offset")})

if any([latest_offset_api in self.api_url for latest_offset_api in _LATEST_OFFSET_APIS]):
if any(
[
latest_offset_api in self.api_url
for latest_offset_api in _LATEST_OFFSET_APIS
]
):
params.update({"latest": self.body.get("offset")})

response = self._client.fetch_next_page( # skipcq: PYL-W0212
Expand Down
6 changes: 4 additions & 2 deletions tests/test_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def test_conversations_history_pagination(self):
conversations = []
limit_size = 1
page_num = 0
for page in self.client.discovery_conversations_history(channel=self.channel, team=self.team, limit=limit_size):
for message in page['messages']:
for page in self.client.discovery_conversations_history(
channel=self.channel, team=self.team, limit=limit_size
):
for message in page["messages"]:
conversations.append(json.dumps(message))
page_num += 1
if page_num > 5:
Expand Down

0 comments on commit d8a593c

Please sign in to comment.