Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pre-commit & Improved contributing.md #193

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: fix-byte-order-marker
- id: forbid-submodules
- id: name-tests-test
args: [--pytest-test-first]
- id: no-commit-to-branch
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
hooks:
- id: poetry-check

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.357
hooks:
- id: pyright
51 changes: 37 additions & 14 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,62 @@ When reporting a bug, make sure to include the versions of `lmo`, `python`,
`numpy` and `scipy` you are using, and provide a **reproducible** example of
the bug.

## Development
## Environment setup

Ensure you have [poetry](https://python-poetry.org/docs/#installation)
installed, then clone your fork, and install with
installed.
It can help to use Lmo's lowest-supported Python version, so that you don't
accidentally use those bleeding-edge Python features that you shouldn't, e.g.

```bash
poetry env use python3.10
```

Now you can install the dev dependencies using

```bash
poetry install --sync
```

It can help to use Lmo's lowest-supported Python version, so that you don't
accidentally use those bleeding-edge Python features that you shouldn't,
`poetry env use python3.x`
### pre-commit

Lmo uses [pre-commit](https://pre-commit.com/) to ensure that the code is
formatted and typed correctly when committing the changes.

Now you can go ahead and do your thing.
And don't forget the type annotations, add tests, and to lint it all.
```bash
poetry run pre-commit install
```

If you're a 10x developer that doesn't wait on CI workflows, you can use the
following 1337 shellscript (keep in mind that the CI runs this on all supported
Python versions):
It can also be manually run:

```bash
poetry run codespell check lmo
poetry run ruff check lmo
poetry run pyright
poetry run py.test
poetry run pre-commit --all-files
```

### Testing

Lmo uses [pytest](https://docs.pytest.org/en/stable/) and
[hypothesis](https://hypothesis.readthedocs.io/en/latest/) as testing
framework.

The tests can be run using

```bash
poetry run pytest
```

## Documentation

If your change involves documentation updates, you can conjure up a live
preview:

```bash
poetry run mkdocs serve
```

This will make the site available at `http://127.0.0.1:8000/`.
It automatically reloads when changes are made to the source code or the
documentation.

But don't worry about building the docs, or bumping the version;
Lmo's personal assistant will do that on release.
Loading