-
-
Notifications
You must be signed in to change notification settings - Fork 16
Team 18 #7
base: master
Are you sure you want to change the base?
Team 18 #7
Conversation
Fix Pipfile dependencies
Exclude virtualenv from Flake8 linting. Again.
double spaces hurt me
Allows you to get human readable level of danger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_danger
is both a fun idea, and particularly well written. rattle.py
should match this level of quality. Docstrings, type hinting and some more comments would help a lot.
tools/rattle.py
Outdated
h = len(otherword) - len(word) | ||
word += '~' * h | ||
return word | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring before helper functions please.
tools/rattle.py
Outdated
@@ -0,0 +1,45 @@ | |||
# rattle - easy word similarity detection | |||
def check_word(word, wordset, threshold=0.8): | |||
def get_shortest(x, y): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These helper functions should also have docstrings.
tools/rattle.py
Outdated
length_diff_multiplier = 1.08 | ||
mp_count = 1 | ||
shorter = '' | ||
if shortest == word: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function desperately needs block comments. runs a bit hot.
[UPDATE] Ignored a silly rule from flake8.
…d fixed a core issue with the command.
bot/cogs/snakes.py
Outdated
from discord.ext.commands import AutoShardedBot, Context, command | ||
|
||
from ..tools import rattle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please no relative imports.
bot/cogs/snakes.py
Outdated
log = logging.getLogger(__name__) | ||
db = load(open('bot/cogs/snek.pickledb', 'rb')) # are we going to move this db elsewhere? | ||
SNAKE_NAMES = db.keys() # make a list of common names for snakes, used for random snake and autocorrect | ||
DEBUG = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded debug mode?
bot/cogs/snakes.py
Outdated
embed.set_footer(text="Information from Wikipedia and snakedatabase.org. Information has been " \ | ||
"automatically fetched and may not be accurate.") | ||
await ctx.send(embed=embed) | ||
|
||
# Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 12 hours to go, you have no extra functionality!
Debug is now based on the presence of the environment variable SNAKES_DEBUG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very few issues, and nothing major. You did a great job documenting the project making your code clear. Can't wait to see what you'll make next Jam!
parent = command.parent | ||
|
||
if parent and command: | ||
help_command = (self.bot.get_command("help"), parent.name, command.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including the (
and )
is unnecessary, you can accomplish the same feat with simply
help_command = self.bot.get_command("help"), parent.name, command.name
f"Sorry, an unexpected error occurred. Please let us know!\n\n```{e}```" | ||
) | ||
raise e.original | ||
log.error(f"COMMAND ERROR: '{e}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't logged if a non-expected CommandInvokeError happens. You could either wrap the ifs in a try - finally block, however just logging the error before you raise it would be fine.
|
||
log.debug(f"{before.display_name} roles changing from {before_role_names} to {after_role_names}") | ||
|
||
if OWNER_ROLE in role_ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do this process twice, you should make a function that does this. Don't repeat yourself 😉
DEBUG = environ.get('SNAKES_DEBUG', None) | ||
dprint = print if DEBUG else lambda *a, **k: None # -1 index is used for easy temp debug hardcode | ||
|
||
SNEK_FACTS = json.loads(open('bot/cogs/facts.json', 'r', encoding='utf-8').read()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never close this file, or the snek,picklebd file.
class NoGuessError(Exception): | ||
def __init__(self, message='', debugdata=None): | ||
self.message = message | ||
self.debugdata = debugdata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is python, let's use _
where there should be a space:
class NoGuessError(Exception):
def __init__(self, message='', debug_data=None):
self.message = message
self.debug_data = debug_data
'💀💀': 'Venomous, harmful', | ||
'💀💀💀': 'Venomous, dangerous', | ||
'💀💀💀💀': 'Venomous, very dangerous', | ||
'💀💀💀💀💀': 'Venomous, extremely dangerous.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved into a json file, that's already loaded?
"Tumblr_m2g660GN9z1qcwgmzo1_1280.png/revision/latest?cb=20120611212456" | ||
scient = 'Chironex fleckeri' | ||
length = '9.8 ft' | ||
custom = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 sneks fall under the same issue as the danger dict. Move this data into a json file!
Woot