Skip to content

Sourcery Starbot ⭐ refactored enthyp/chat#15

Open
SourceryAI wants to merge 1 commit intoenthyp:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored enthyp/chat#15
SourceryAI wants to merge 1 commit intoenthyp:masterfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

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/chat master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -88 to +89
else:
log.err('DB: password_correct CALL FAILURE: no such user in database')
raise failure.Failure(sqlite3.IntegrityError())
log.err('DB: password_correct CALL FAILURE: no such user in database')
raise failure.Failure(sqlite3.IntegrityError())
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function DBService.password_correct refactored with the following changes:

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

Comment on lines -177 to +176
results = yield self._dbpool.runQuery(query.select_notifications, (user,))
return results
return (yield self._dbpool.runQuery(query.select_notifications, (user,)))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function DBService.get_notifications refactored with the following changes:

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

for k, v in self.user2peer.items():
if v == peer:
nicks.append(k)
nicks = [k for k, v in self.user2peer.items() if v == peer]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Dispatcher.remove_peer refactored with the following changes:

  • Convert for loop into list comprehension (list-comprehension)

else:
if self.connected:
self.endpoint.no_channel(channel_name)
pass
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function LoggedInState.msg_JOIN refactored with the following changes:

  • Remove redundant pass statement (remove-redundant-pass)

Comment on lines -97 to +98
if message.strip(" ") != "":
if self.client:
self.client.handle_input(message.strip(" "))
if message.strip(" ") != "" and self.client:
self.client.handle_input(message.strip(" "))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function GUI.send_message refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)

"""Connects to the specific database."""
conn = sqlite3.connect(app.config['DATABASE'])
return conn
return sqlite3.connect(app.config['DATABASE'])
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function connect_db refactored with the following changes:

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

# extracts all channels from records and returns list
def extract_channels(rows):
return list(set([row[1] for row in rows]))
return list({row[1] for row in rows})
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function extract_channels refactored with the following changes:

  • Replace unneeded comprehension with generator (comprehension-to-generator)
  • Replace list(), dict() or set() with comprehension (collection-builtin-to-comprehension)

Comment on lines -72 to +73
for i in range(0, len(ratings_list)):
for j in range(0, 6):
for i in range(len(ratings_list)):
for j in range(6):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function history refactored with the following changes:

  • Replace range(0, x) with range(x) (remove-zero-from-range)

Comment on lines -98 to +99
for i in range(0, len(ratings_list)):
for j in range(0, 6):
for i in range(len(ratings_list)):
for j in range(6):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function channel refactored with the following changes:

  • Replace range(0, x) with range(x) (remove-zero-from-range)

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