Skip to content

Commit 3918267

Browse files
authored
Improve CONTRIBUTING guidelines (#141)
* improve local development description * add comment about pre-commit fix
1 parent d0f3e9a commit 3918267

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
- id: mypy
2525
args: [--ignore-missing-imports]
2626
files: ^pymc_bart/
27-
additional_dependencies: [numpy<1.25.0, pandas-stubs]
27+
additional_dependencies: [numpy<1.25.0, pandas-stubs==1.5.3.230304]
2828
- repo: https://github.com/pre-commit/pre-commit-hooks
2929
rev: v3.2.0
3030
hooks:

CONTRIBUTING.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Thanks for your interest in contributing code to pymc_bart!
1515

1616
**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**
1717

18+
### Local Development
19+
20+
0. Create a virtual environment (optional, but strongly recommended)
21+
22+
1. Install the library in editable mode
23+
24+
```bash
25+
pip install -e .
26+
```
27+
1828
### Feature Branch
1929

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

4353
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:
4454

45-
0. Create a virtual environment (optional, but strongly recommended)
46-
4755
1. Install pre-commit
4856

4957
```bash
@@ -70,13 +78,57 @@ pre-commit run --all-files
7078

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

81+
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.
82+
7383
You can skip this (for example when is WIP) by adding a flag (`-n` means no-verify)
7484

7585
```bash
7686
git commit -m"my message" -n
7787
```
7888

79-
**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.
89+
### Pre-Commit Components
90+
91+
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.
92+
93+
#### Ruff
94+
95+
Once installed locally as
96+
97+
```
98+
pip install ruff==<VERSION>
99+
```
100+
101+
You can check the lint as
102+
103+
```bash
104+
ruff . --no-fix
105+
```
106+
107+
You can allow `ruff` to fix the code by using the flag:
108+
109+
```bash
110+
ruff . --fix
111+
```
112+
113+
#### MyPy
114+
115+
We use `mypy` to check the type annotations. Once installed locally as
116+
117+
```bash
118+
pip install mypy==<VERSION>
119+
```
120+
121+
You also need the `pandas-stubs` library with the version specified in the [`.pre-commit-config.yaml`](.pre-commit-config.yaml) file.
122+
123+
```bash
124+
pip install pandas-stubs==<VERSION>
125+
```
126+
127+
Now, you can check the type annotations as
128+
129+
```bash
130+
mypy pymc_bart/.
131+
```
80132

81133
### Adding new features
82134
If you are interested in adding a new feature to pymc_bart,

0 commit comments

Comments
 (0)