hedy icon indicating copy to clipboard operation
hedy copied to clipboard

Introduce automated checks for PEP8-compliance using flake8

Open mennoliefstingh opened this issue 2 years ago • 0 comments

Description

This pull request serves as a first step towards making Hedy a PEP8-compliant project by introducing automatic linting of code using flake8. Flake8 is configured in setup.cfg, with a set max line length of 100 and an exclusion of rule F541 (f-strings without placeholders) for the tests folder.

Two checks are added to the repository. First of all, it introduces a Git pre-commit hook that developers can install to automatically lint modified code on each commit. Secondly, it introduces a Github Actions workflow that lints the code on pushes and pull requests. It is possible to configure this Workflow such that failing the linting denies the pull request, but as that is outside the scope of issue 3377 I will make a new issue about making the entire codebase PEP8-compliant.

Finally, CONTRIBUTING.md is updated with instructions for using the Git pre-commit hook, instructions for using autopep8 to automatically fix some issues and a friendly request to make sure all new or modified code is PEP8-compliant.

Fixes issue #3377

How to test

To test the Git pre-commit hook, follow these commands:

pip install pre-commit
pre-commit install  # installs the pre-commit configuration from pre-commit-config.yml

After this, stage a commit with Python code and your commit will be prevented if your modifications fail the linting. You can force a commit by adding a --no-verify flag to your git commit.

To test the Github action, simply push to the repository and visit the 'Actions' tab in Github: you should see the results of the linting in the workflow.

mennoliefstingh avatar Oct 12 '22 21:10 mennoliefstingh