davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.86k stars 974 forks source link

lint and refactor tiktok.py #240

Closed hoylemd closed 4 years ago

hoylemd commented 4 years ago

While working on #238, I saw a lot of linting errors.

So I fixed them!

I also redid requirements.txt to pin all dependency versions. This is just a general best-practice. I also added flake8 to the list of requirements so anyone using a virtual environment to work on this library will have a linter available. Added a config part to setup.cfg as well.

I also refactored all of the querystring creation to use urllib.parse.urlencode instead of string concatentation/interpolation. This way, the querystring is declared in a much easier-to-maintain-and-read way (e.g. if you want to make any of the hard-coded query params variable, you just have to change the dict slightly)

I ran the tests frequently using pytest as a runner. I considered adding that to requirements.txt as well, but decided against it because I don't know what test runner @davidteather uses.

I added extra context to some of the commit messages to explain why I made a change, in case it's not obvious.

Actual functionality should remain unchanged.

hoylemd commented 4 years ago

Ah backwards compatability, Foiled me again!

Alright, I'll revert the requirements changes. To be fair, I'm running python 3.8 so I'm probably getting very new versions of stuff that aren't backwards compatable.

I'll push that up in a bit :)