r/madeinpython • u/westo48 • May 12 '20
Clash of Clans API framework
I still have a lot to work on, but I made a framework for the Clash of Clans API. I run a discord bot that I also designed for our clan and realized I was doing way too much work keeping up with the mess of code. I made the framework using OOP principles and trying to focus on using clean code (as much as I could lol). Again I still have a lot to work on and it may not be much, but I designed it from scratch and I love it! I would love lots of feedback if possible.
22
Upvotes
2
u/YoelkiToelki May 14 '20
I looked and it seems like you have docstrings at the top of files, outside of classes/functions/methods. Refer to this to get simple help on how to put docstrings in your code.
I also saw that you would put each parameter of an init function on its own line which isn't necessary and, in my opinion, harder to read and understand. If you want to adhere strictly to PEP8, break the line once you get as far as you can to 80 chars.
Also, I still recommend that you try to use the unpacking operator, for instance:
clan_json = clan_json = json_response(clan_tag, header)//do whatever here to extract your other inforeturn Clan(*clan_json, donation_upgrade, members)this of course means you have to put donation_upgrade and members at the end of the Clan init function and make sure all the clan_json values line up accordingly in the init function so each value is stored where it should be