Skip to content

Conversation

@SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/python-slackclient master
git merge --ff-only FETCH_HEAD
git reset HEAD^

system_info = "{0}/{1}".format(platform.system(), platform.release())
user_agent_string = " ".join([python_version, client, system_info])
return user_agent_string
return " ".join([python_version, client, system_info])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BaseClient._get_user_agent refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -184 to -189
present = (
return (
"response_metadata" in data
and "next_cursor" in data["response_metadata"]
and data["response_metadata"]["next_cursor"] != ""
)
return present
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SlackResponse._next_cursor_is_present refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -190 to +196
if self.data_source == "external":
if isinstance(self.value, Option):
if isinstance(self.value, Option):
if self.data_source == "external":
json["selected_options"] = extract_json([self.value], "dialog")
elif self.value is not None:
json["selected_options"] = Option.from_single_value(self.value)
else:
if isinstance(self.value, Option):
else:
json["value"] = self.value.value
elif self.value is not None:
json["value"] = self.value
elif self.value is not None:
json["selected_options"] = Option.from_single_value(self.value)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AbstractDialogSelector.to_dict refactored with the following changes:

  • Hoist repeated code outside conditional statement (hoist-statement-from-if)

self._state = dumps(state)
else:
self._state = state
self._state = dumps(state) if isinstance(state, dict) else state
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DialogBuilder.state refactored with the following changes:

  • Replace if statement with if expression (assign-if-exp)

self.state = json.loads(event["state"])
else:
self.state = {}
self.state = json.loads(event["state"]) if event["state"] else {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DialogInteractiveEvent.__init__ refactored with the following changes:

  • Replace if statement with if expression (assign-if-exp)


def fake_req_args(headers=ANY, data=ANY, params=ANY, json=ANY):
req_args = {
return {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fake_req_args refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -24 to +23
req_args = {
return {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fake_send_req_args refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -87 to +88
else:
self.assertEqual(rtm_client._connection_attempts, 2)
rtm_client.stop()
self.assertEqual(rtm_client._connection_attempts, 2)
rtm_client.stop()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestRTMClientFunctional.test_client_auto_reconnects_if_an_error_is_thrown.stop_on_open refactored with the following changes:

  • Remove unnecessary else after guard condition (remove-unnecessary-else)

users = []
for page in self.client.users_list(limit=2):
users = users + page["members"]
users += page["members"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestWebClient.test_requests_can_be_paginated refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

users = []
for page in self.client.users_list(limit=2):
users = users + page["members"]
users += page["members"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestWebClient.test_request_pagination_stops_when_next_cursor_is_missing refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant