diff --git a/.github/workflows/flake8.yaml b/.github/workflows/flake8.yaml new file mode 100644 index 00000000..a22b3715 --- /dev/null +++ b/.github/workflows/flake8.yaml @@ -0,0 +1,24 @@ +# This workflow runs Flake8 on the PR +# For more information see: https://github.com/marketplace/actions/python-flake8-lint +name: PyLops-flake8 + +on: [push, pull_request] + +jobs: + flake8-lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Check out source repository + uses: actions/checkout@v2 + - name: Set up Python environment + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: flake8 Lint + uses: py-actions/flake8@v2 + with: + ignore: "E203,E501,W503,E402" + max-line-length: "88" + path: "pylops" + args: "--per-file-ignores=__init__.py:F401,F403,F405" diff --git a/Makefile b/Makefile index 496c3d30..2d5ea7b7 100755 --- a/Makefile +++ b/Makefile @@ -39,3 +39,6 @@ doc: docupdate: cd docs && make html && cd .. + +lint: + flake8 docs/ examples/ pylops/ pytests/ tutorials/ diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 3076cda3..1d411208 100755 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -91,17 +91,26 @@ that the both old and new tests pass successfully: >> make tests -7. Commit your changes and push your branch to GitLab: +7. Run flake8 to check the quality of your code: .. code-block:: bash - >> git add . + >> make lint + +Note that at this point we are not enforcing flake8, rather this is used as a guideline and will also be run as +part of our CI. Make sure to limit to a minimum flake8 warnings before making a PR. + +8. Commit your changes and push your branch to GitHub: + +.. code-block:: bash + + >> git add . >> git commit -m "Your detailed description of your changes." >> git push origin name-of-your-branch Remember to add ``-u`` when pushing the branch for the first time. -8. Submit a pull request through the GitHub website. +9. Submit a pull request through the GitHub website. Pull Request Guidelines diff --git a/environment-dev.yml b/environment-dev.yml index e8b608f7..c1657cc4 100755 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -31,3 +31,4 @@ dependencies: - sphinx-gallery - nbsphinx - image + - flake8 diff --git a/requirements-dev.txt b/requirements-dev.txt index abade6c0..a15b571d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -22,3 +22,4 @@ pre-commit autopep8 isort black +flake8 diff --git a/setup.cfg b/setup.cfg index efc2cf4c..aeb0c970 100755 --- a/setup.cfg +++ b/setup.cfg @@ -4,3 +4,9 @@ test=pytest [tool:pytest] addopts = --verbose python_files = pytests/*.py + +[flake8] +ignore = E203, E501, W503, E402 +per-file-ignores = + __init__.py: F401, F403, F405 +max-line-length = 88