Reduce Reliance on Tuples #18
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Various parts of the bot rely on tuples and arrays to pass data between functions:
command, full_user, arguments, note_obj = parsed_command
return [command,full_user, arguments, note_obj]
return None, None, None, None
return chosen['id'], chosen['name'], chosen['file_id'], chosen['rarity']
(This list is not exhaustive)
Occurences of returned tuples and arrays should be replaced with dictionaries. Dictionaries allow us to reference members by name instead of index, allowing for clearer and more maintainable code:
Becomes:
Notably, accessing data becomes more explicit and allows for adding, removing, or reordering members of the tuple without having to update all references to it. It's now much more clear what is being returned. Dictionaries also support the
get()
accessor, which allows for default arguments, making@nai Thoughts on this approach?
It's just my opinion, but tuples tend to rub me the wrong way when I see them.
I like the implementation, I actually didn't understood it fully until I was rewriting the pr #42, but especifies a lot of things and makes functions more explicit. Let's go with it absolutely 💯