Sourcery Starbot ⭐ refactored marks/python-slackclient#1
Sourcery Starbot ⭐ refactored marks/python-slackclient#1SourceryAI wants to merge 1 commit intomarks:masterfrom
Conversation
| 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]) |
There was a problem hiding this comment.
Function BaseClient._get_user_agent refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| present = ( | ||
| return ( | ||
| "response_metadata" in data | ||
| and "next_cursor" in data["response_metadata"] | ||
| and data["response_metadata"]["next_cursor"] != "" | ||
| ) | ||
| return present |
There was a problem hiding this comment.
Function SlackResponse._next_cursor_is_present refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 {} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Function fake_req_args refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| req_args = { | ||
| return { |
There was a problem hiding this comment.
Function fake_send_req_args refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| else: | ||
| self.assertEqual(rtm_client._connection_attempts, 2) | ||
| rtm_client.stop() | ||
| self.assertEqual(rtm_client._connection_attempts, 2) | ||
| rtm_client.stop() |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
Function TestWebClient.test_request_pagination_stops_when_next_cursor_is_missing refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign)
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
masterbranch, then run: