Skip to content

Commit

Permalink
Use pre-commit hooks for auto-linting, deprecate python 3.8 support (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins authored Jan 30, 2024
1 parent 88fa423 commit 4ca5b5e
Show file tree
Hide file tree
Showing 180 changed files with 11,563 additions and 7,984 deletions.
17 changes: 8 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@
$ py.test -v -s africanus
```

If the pep8 tests fail, the quickest way to correct
this is to run `autopep8` and then `flake8` and
`pycodestyle` to fix the remaining issues.
If the pre-commit tests fail, install and
run the pre-commit hooks in your development
virtuale environment:

```
$ pip install -U autopep8 flake8 pycodestyle
$ autopep8 -r -i africanus
$ flake8 africanus
$ pycodestyle africanus
```bash
$ pip install pre-commit
$ pre-commit install
$ pre-commit run -a
```

- [ ] Fully documented, including `HISTORY.rst` for all changes
and one of the `docs/*-api.rst` files for new API

To build the docs locally:

```
```bash
pip install -r requirements.readthedocs.txt
cd docs
READTHEDOCS=True make html
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -45,7 +45,7 @@ jobs:
run: pipenv install .[testing]

- name: Run base test suite
run: pipenv run NUMBA_NRT_STATS=1 py.test --flake8 -s -vvv africanus/
run: pipenv run NUMBA_NRT_STATS=1 py.test -s -vvv africanus/

- name: List the measures directory
run: curl ftp://ftp.astron.nl/outgoing/Measures/ > measures_dir.txt
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
run: pipenv graph

- name: Run complete test suite
run: pipenv run NUMBA_NRT_STATS=1 py.test --flake8 -s -vvv africanus/
run: pipenv run NUMBA_NRT_STATS=1 py.test -s -vvv africanus/

deploy:
needs: [test]
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on: [push]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/[email protected]
with:
python-version: 3.11
- uses: pre-commit/[email protected]
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff-format
name: ruff format
29 changes: 14 additions & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,35 @@ Ready to contribute? Here's how to set up `codex-africanus` for local developmen

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv codex-africanus
$ cd codex-africanus/
$ python -m venv ./africanus
$ source ./africanus/bin/activate
$ pip install -e .

4. Create a branch for local development::
4. Install the pre-commit hooks

$ pip install pre-commit
$ pre-commit install

5. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes
6. When you're done making changes, check that your changes
pass the test cases, fixup your PEP8 compliance,
and check for any code style issues:

$ py.test -v africanus
$ autopep8 -r -i africanus
$ flake8 africanus
$ pycodestyle africanus

To get autopep8 and pycodestyle, just pip install them into your virtualenv.
$ py.test -vvv africanus
$ pre-commit run -a

6. Commit your changes and push your branch to GitHub::
7. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.
8. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------
Expand All @@ -104,9 +105,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in HISTORY.rst.
3. The pull request should work for Python 2.7, 3.5 and 3.6. Check
https://travis-ci.org/ska-sa/codex-africanus/pull_requests
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for Python 3.9 and above.

Tips
----
Expand Down
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ History

X.Y.Z (YYYY-MM-DD)
------------------
* Deprecate python 3.8 support (:pr:`290`)
* Use pre-commit hooks for auto-linting (:pr:`290`)
* Deprecate use of @generated_jit. Remove upper bound on numba. (:pr:`289`)
* Remove unnecessary new_axes in calibration utils after upstream fix in dask (:pr:`288`)
* Check that ncorr is never larger than 2 in calibration utils (:pr:`287`)
Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ Documentation
-------------

https://codex-africanus.readthedocs.io.

Loading

0 comments on commit 4ca5b5e

Please sign in to comment.