C0D3D3V / Moodle-DL

Moodle-DL downloads course content fast from Moodle (eg. lecture pdfs)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reformat using black and use the correct format of type hints

roeekl opened this issue · comments

Avoid duplicates

  • This enhancement request has not already been raised before

Is your feature request related to a problem? Please describe.

Not a major problem, but the code base should follow PEP 8 (Python Style Guide) and PEP 484 (Type Hints)

Describe the solution you'd like

We should use black formatter on the entire codebase, and also change each incorrect type hints to its correct format.

Describe alternatives you've considered

None.

Additional context

About the formatting: If you will agree to reformat the code base, we first need to decide if we want to change anything in black's configuration (e.g the default line length is 80 characters which is pretty short).
About the Type Hints: I already changed the code, hope you will agree and can approve this PR.
We also should use the git --ignore-revs-file option so that it won't show on git blame.

I think these are all good ideas. Feel free to do a PR.
I actually preferred short lines and only added the rule because I liked it. But if you think longer lines would improve readability, feel free to change it.

About black:

So let's agree that the default configuration is ok. Do we want to enforce the commits and the pull requests of this repo with black? if so, we need to add Github Action and maybe precommit configuration.

If you have an idea how to add checks to PRs you can try it. On an other project I'm working on ddnet they use a bot borg to run the CI and style checks before merging is allowed (the bot merges it if all checks were sucessful), this is pretty nice, this way you can still bypass the rules by just pushing directly to main, but they forbid it, and tell the devs to only do it in an emergency. But I heard you can now also run the Ci/Actions on PRs without an bot, so if you know how to do it you are welcome to do so.

I'm also not sure if we have fixed all black issues (I think they should be fixed before, or at least with an follow up PR, so that other PR do not have to struggle with the issues).
Also it would be pretty nice if we would have a way to fix the black issues by just running a fix_style script that trys to fix all black issues automaticlly or report all issues that needs to be fixed manual.

I added the black action to the project (currently in a dev branch) https://github.com/C0D3D3V/Moodle-Downloader-2/actions/runs/4033295689/jobs/6933717887
I guess that should do the job for now. But we can still change the settings if we want...

I guess adding a flake8 and pylint action would be nice to