Skip to content

Commit

Permalink
Improve CONTRIBUTING guidelines (#141)
Browse files Browse the repository at this point in the history
* improve local development description

* add comment about pre-commit fix
  • Loading branch information
juanitorduz authored Feb 5, 2024
1 parent d0f3e9a commit 3918267
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: mypy
args: [--ignore-missing-imports]
files: ^pymc_bart/
additional_dependencies: [numpy<1.25.0, pandas-stubs]
additional_dependencies: [numpy<1.25.0, pandas-stubs==1.5.3.230304]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
Expand Down
58 changes: 55 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ Thanks for your interest in contributing code to pymc_bart!

**If this is your first time contributing to a project on GitHub, please read through our step by step guide to contributing to pymc_bart**

### Local Development

0. Create a virtual environment (optional, but strongly recommended)

1. Install the library in editable mode

```bash
pip install -e .
```

### Feature Branch

1. From the fork of the pymc_bart repository, create a new branch for your feature.
Expand Down Expand Up @@ -42,8 +52,6 @@ git push origin feature_branch_name

The repository has some code style checks in place. This will happen on every commit of a pull request. If you want to run the checks locally, you can do so by running the following command from the root of the repository:

0. Create a virtual environment (optional, but strongly recommended)

1. Install pre-commit

```bash
Expand All @@ -70,13 +78,57 @@ pre-commit run --all-files

**Once you commit something the pre-commit hook will run all the checks**!

In particular, if the commited changed have linting errors, the commit will try to fix them. If successful,you need to add the changes again (for example, `git add -u`) and commit again. If not successful, you need to fix the errors manually and commit again.

You can skip this (for example when is WIP) by adding a flag (`-n` means no-verify)

```bash
git commit -m"my message" -n
```

**Remark:** One can, of course, install `ruff` in the Python environment to enable auto-format (for example in VS Code), but this is not strictly necessary. The specific versions of` ruff` and `mypy` must be only specified in `.pre-commit-config.yaml`. It should be the only source of truth! Hence, if you want to install them locally make sure you use the same versions (revisions `rev` in the config file) as in the config file.
### Pre-Commit Components

One can, of course, install `ruff` in the Python environment to enable auto-format (for example in VS Code), but this is not strictly necessary. The specific versions of` ruff` and `mypy` must be only specified in [`.pre-commit-config.yaml`](.pre-commit-config.yaml). It should be the only source of truth! Hence, if you want to install them locally make sure you use the same versions (revisions `rev` in the config file) as in the config file.

#### Ruff

Once installed locally as

```
pip install ruff==<VERSION>
```

You can check the lint as

```bash
ruff . --no-fix
```

You can allow `ruff` to fix the code by using the flag:

```bash
ruff . --fix
```

#### MyPy

We use `mypy` to check the type annotations. Once installed locally as

```bash
pip install mypy==<VERSION>
```

You also need the `pandas-stubs` library with the version specified in the [`.pre-commit-config.yaml`](.pre-commit-config.yaml) file.

```bash
pip install pandas-stubs==<VERSION>
```

Now, you can check the type annotations as

```bash
mypy pymc_bart/.
```

### Adding new features
If you are interested in adding a new feature to pymc_bart,
Expand Down

0 comments on commit 3918267

Please sign in to comment.