Lint code with Flake8

(ignore line length issues for now)
master
Tristan Gosselin-Hane 6 years ago
parent 8560604c29
commit 1e0ef1426f
No known key found for this signature in database
GPG Key ID: D2282BE1CF7B78DA
  1. 2
      .flake8
  2. 2
      minecraft-discord-bridge/auth_server.py
  3. 1
      minecraft-discord-bridge/config.py
  4. 12
      minecraft-discord-bridge/minecraft_discord_bridge.py

@ -0,0 +1,2 @@
[flake8]
ignore = E501

@ -47,7 +47,7 @@ class AuthProtocol(ServerProtocol):
return
if datetime.utcnow() < token.expiry:
# Check if they already have a linked account and are re-linking
if discord_account.minecraft_account_id != None:
if discord_account.minecraft_account_id is not None:
existing_account = session.query(MinecraftAccount).filter_by(
id=discord_account.minecraft_account_id).first()
self.logger.info("unlinking existing {} account and replacing it with {}".format(

@ -3,6 +3,7 @@ import logging
log = logging.getLogger("bridge.config")
class Configuration(object):
def __init__(self, path):
try:

@ -75,7 +75,7 @@ def mc_username_to_uuid(username):
long_uuid = uuid.UUID(player_uuid)
UUID_CACHE.inv[username] = str(long_uuid)
return player_uuid
except:
except requests.RequestException:
log.error("Failed to lookup {}'s UUID using the Mojang API.".format(username))
else:
return UUID_CACHE.inv[username]
@ -294,7 +294,7 @@ def main():
'embeds': [{'color': 65280, 'title': '**Joined the game**'}]
}
for webhook in WEBHOOKS:
post = requests.post(webhook,json=webhook_payload)
requests.post(webhook, json=webhook_payload)
if config.es_enabled:
el.log_connection(
uuid=action.uuid, reason=el.ConnectionReason.CONNECTED, count=len(PLAYER_LIST))
@ -305,8 +305,8 @@ def main():
ACCEPT_JOIN_EVENTS = True
if config.es_enabled:
diff = set(PREVIOUS_PLAYER_LIST.keys()) - set(PLAYER_LIST.keys())
for idx, uuid in enumerate(diff):
el.log_connection(uuid=uuid, reason=el.ConnectionReason.DISCONNECTED,
for idx, player_uuid in enumerate(diff):
el.log_connection(uuid=player_uuid, reason=el.ConnectionReason.DISCONNECTED,
count=len(PREVIOUS_PLAYER_LIST) - (idx + 1))
# Don't bother announcing the bot's own join message (who cares) but log it for analytics still
if config.es_enabled:
@ -326,7 +326,7 @@ def main():
'embeds': [{'color': 16711680, 'title': '**Left the game**'}]
}
for webhook in WEBHOOKS:
post = requests.post(webhook,json=webhook_payload)
requests.post(webhook, json=webhook_payload)
del UUID_CACHE[action.uuid]
del PLAYER_LIST[action.uuid]
if config.es_enabled:
@ -373,7 +373,7 @@ def main():
'content': '{}'.format(message)
}
for webhook in WEBHOOKS:
post = requests.post(webhook, json=webhook_payload)
requests.post(webhook, json=webhook_payload)
if config.es_enabled:
el.log_chat_message(
uuid=player_uuid, display_name=username, message=original_message, message_unformatted=chat_string)

Loading…
Cancel
Save