super-mario-python icon indicating copy to clipboard operation
super-mario-python copied to clipboard

feat: move to poetry + pre commit linting

Open danisc23 opened this issue 2 years ago • 1 comments

Description

This PR moves from pip requirements to poetry, this way we can ensure that everyone uses same python version and dependecies.

Also adds pre-commit for formatting and linting and be more compliant with code style

Details

  • Added pyproject.toml for poetry and remove requirements.txt
  • Added .pre-commit-config.yaml as this repository format and linting suite
  • Added a github action to check if a PR is compliant with pre-commit
  • Updated README.md
  • pre-commit fixed automatically most of the python and json files to be compliant with the codestyle

About pre-commit checks

General checks

  • Avoid users to commit changes in master (even locally)
  • Checks that JSON files are valid
  • Prettify JSON files (if needed)
  • Normalizes end of files and end of lines to avoid trailing whitespaces
  • Ensures that the PR doesn't include any line introduced for local debugging

Python Checks

  • Code is formatted automatically with black (codestyle), autoflake (remove unused imports and variables) and isort (import sorting)
  • Flake8 as general linter
  • Mypy for typing checks

danisc23 avatar Oct 14 '23 18:10 danisc23

@mx0c I can't add you as a reviewer, but let me know if you have any question about this PR.

I only added one github action to check linting, but I think it's a good idea to open at least 2 more to ensure that a PR acomplish the following:

  • Run unit tests (need tests first 😄 ) -> With this we can check that every function still doing what we expect from them even if something is changed, also works very good as documentation 😃
  • A check that runs main.py without crashing -> The game is still working as expected in the PR
  • Linting (added in this PR) -> changed code is compliant with the repository codestyle

danisc23 avatar Oct 14 '23 18:10 danisc23