Skip to content

Commit

Permalink
docs(developer): document ruff, mention modflow-devtools, cleanup (#2185
Browse files Browse the repository at this point in the history
)

* mention modflow-devtools testing dependency in DEVELOPER.md, motivated by #2180
* update CONTRIBUTING.md and DEVELOPER.md with info on ruff instead of black/isort
* update etc/environment.yml lint deps (ruff replaces black/isort/flake8/pylint)
* remove scripts/pull_request_prepare.py, suggest ruff commands instead
* update .github/workflows/release.yml to use ruff
  • Loading branch information
wpbonelli authored May 6, 2024
1 parent 344579b commit 12f80dc
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 42 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ jobs:
python -c "import flopy; print(f'FloPy version: {flopy.__version__}')"
echo "version=${ver#"v"}" >> $GITHUB_OUTPUT
- name: Lint Python files
run: python scripts/pull_request_prepare.py
- name: Lint and format Python files
run: |
ruff check . --fix
ruff format .
- name: Run tests
working-directory: autotest
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ Before you submit your Pull Request (PR) consider the following guidelines:
5. Run the formatting tools from the project root:

```shell
black -v flopy
isort -v flopy
ruff check .
ruff format .
```

Note: Pull Requests must pass format checks run on the [GitHub actions](https://github.com/modflowpy/flopy/actions) before they will be accepted. If the Pull Request fails the `lint` job in the [continuous integration](https://github.com/modflowpy/flopy/actions/workflows/commit.yml) workflow, make sure the latest versions of `black` and `isort` are installed (this may require clearing CI caches).
Note: Pull Requests must pass format checks run on the [GitHub actions](https://github.com/modflowpy/flopy/actions) before they will be accepted. If the Pull Request fails the `lint` job in the [continuous integration](https://github.com/modflowpy/flopy/actions/workflows/commit.yml) workflow, make sure the latest version of `ruff` is installed (this may require clearing CI caches).

6. Run the full FloPy test suite and ensure that all tests pass:

Expand Down
4 changes: 3 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ Each example should create and (attempt to) dispose of its own isolated temporar

To run the tests you will need `pytest` and a few plugins, including [`pytest-xdist`](https://pytest-xdist.readthedocs.io/en/latest/), [`pytest-dotenv`](https://github.com/quiqua/pytest-dotenv), and [`pytest-benchmark`](https://pytest-benchmark.readthedocs.io/en/latest/index.html). Test dependencies are specified in the `test` extras group in `pyproject.toml` (with pip, use `pip install ".[test]"`). Test dependencies are included in the Conda environment `etc/environment`.

**Note:** to prepare your code for a pull request, you will need a few more packages specified in the `lint` extras group in `pyproject.toml` (also included by default for Conda). See the docs on [submitting a pull request](CONTRIBUTING.md) for more info.
**Note:** tests require the [`modflow-devtools`](https://github.com/MODFLOW-USGS/modflow-devtools) package, which is a grab bag of utilities and `pytest` fixtures shared by FloPy, MODFLOW 6, and other related projects. If you see testing errors that don't seem related to the contents of the tests, updating to the latest `modflow-devtools` is recommended as a first troubleshooting step.

**Note:** to prepare your code for a pull request, you will need the [`ruff`](https://docs.astral.sh/ruff/) linter/formatter, which is included in the `lint` extras group in `pyproject.toml` (also included by default for Conda). See the docs on [submitting a pull request](CONTRIBUTING.md) for more info.

### Configuring tests

Expand Down
4 changes: 2 additions & 2 deletions docs/make_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ As described above, making a release manually involves the following steps:

- Update MODFLOW 6 dfn files in the repository and MODFLOW 6 package classes by running `python -m flopy.mf6.utils.generate_classes --ref master --no-backup`

- Run `isort` and `black` on the `flopy` module. This can be achieved by running `python scripts/pull_request_prepare.py` from the project root. The commands `isort .` and `black .` can also be run individually instead.
- Run `ruff check .` and `ruff format .` from the project root.

- Use `run_notebooks.py` in the `scripts` directory to rerun all notebooks in `.docs/Notebooks`.

Expand All @@ -121,7 +121,7 @@ As described above, making a release manually involves the following steps:

2. Set the development version as appropriate: `python scripts/update_version.py -v <version>`. The version number must comply with [PEP 440](https://peps.python.org/pep-0440/).

3. Lint Python files: `python scripts/pull_request_prepare.py`
3. Lint and format Python files: `ruff check .` and `ruff format .` from the project root.

4. Commit and push the updated `develop` branch.

Expand Down
5 changes: 1 addition & 4 deletions etc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ dependencies:
- matplotlib>=1.4.0

# lint
- black
- cffconvert
- flake8
- isort
- pylint
- ruff

# test
- coverage
Expand Down
9 changes: 0 additions & 9 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This document describes the utility scripts in this directory.
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Processing benchmarks](#processing-benchmarks)
- [Preparing for PRs](#preparing-for-prs)
- [Running notebooks](#running-notebooks)
- [Updating version](#updating-version)

Expand All @@ -29,14 +28,6 @@ For instance, `e689af57e7439b9005749d806248897ad550eab5_20150811_041632_uncommit

**Note**: the `process_benchmarks.py` script depends on `seaborn`, which is not included as a dependency in either `etc/environment.yml` or in any of the optional groups in `pyproject.toml`, since this is the only place it is used in this repository.

## Preparing for PRs

The `pull_request_prepare.py` script lints Python source code files by running `black` and `isort` on the `flopy` subdirectory. This script should be run before opening a pull request, as CI will fail if the code is not properly formatted. For instance, from the project root:

```shell
python scripts/pull_request_prepare.py
```

## Running notebooks

The `run_notebooks.py` script runs notebooks located in the `.docs/Notebooks` directory.
Expand Down
21 changes: 0 additions & 21 deletions scripts/pull_request_prepare.py

This file was deleted.

0 comments on commit 12f80dc

Please sign in to comment.