Skip to content

Commit b102c3c

Browse files
authored
Add pre-commit (#13)
1 parent 7e5a15b commit b102c3c

File tree

7 files changed

+73
-159
lines changed

7 files changed

+73
-159
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file configures editors, IDEs, and prettier
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
max_line_length = 88
11+
indent_size = 4
12+
indent_style = space
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.github/workflows/pytest.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ jobs:
1919
id: setup_py
2020
uses: actions/setup-python@v4
2121
with:
22-
python-version: '3.10'
23-
cache: 'poetry'
22+
python-version: "3.10"
23+
cache: poetry
2424

2525
- name: Poetry install
2626
run: |
2727
poetry lock --check # check that lockfile is up to date
28-
poetry install --with test,dev --extras annlibs
28+
poetry install --with test --extras annlibs
2929
3030
- name: Run test suite
3131
run: |
3232
poetry run pytest -v --color=yes
3333
34-
- name: Run formatter
35-
run: |
36-
poetry run black --check .
37-
38-
- name: Run style checks
39-
run: |
40-
poetry run ruff .
34+
check: # TODO: replace with pre-commit.ci
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-python@v4
39+
with:
40+
python-version: "3.10"
41+
cache: pip
42+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
- id: check-case-conflict
9+
- id: check-toml
10+
- id: check-yaml
11+
- id: check-merge-conflict
12+
- id: detect-private-key
13+
- id: no-commit-to-branch
14+
args: ["--branch=main"]
15+
- repo: https://github.com/psf/black
16+
rev: "23.3.0"
17+
hooks:
18+
- id: black
19+
- repo: https://github.com/charliermarsh/ruff-pre-commit
20+
rev: v0.0.275
21+
hooks:
22+
- id: ruff
23+
args: ["--fix"]
24+
- repo: https://github.com/pre-commit/mirrors-prettier
25+
rev: v2.7.1
26+
hooks:
27+
- id: prettier

README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,21 @@ reason is that currently the only neighbourhood algorithms which are
3131
build into scikit-learn are essentially the standard tree approaches
3232
to space partitioning: the ball tree and the K-D tree. These do not
3333
perform competitively in high dimensional spaces.
34+
35+
Development
36+
===========
37+
38+
This project is managed using Poetry_ and pre-commit_.
39+
To get started, run ``pre-commit install`` once and ``poetry install ...``
40+
whenever dependencies have changed. E.g. @flying-sheep runs::
41+
42+
poetry install --with=test --extras=annlibs
43+
44+
This installs all optional (dev) dependencies except for those to build the docs.
45+
pre-commit_ comes into play on every `git commit` after installation.
46+
47+
Consult ``pyproject.toml`` for which dependency groups and extras exist,
48+
and the poetry help or user guide for more info on what they are.
49+
50+
.. _poetry: https://python-poetry.org/
51+
.. _pre-commit: https://pre-commit.com/

poetry.lock

Lines changed: 1 addition & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ pynndescent = ["pynndescent"]
2222
nmslib = ["nmslib"]
2323
annlibs = ["annoy", "faiss-cpu", "pynndescent", "nmslib"]
2424

25-
[tool.poetry.group.dev]
26-
optional = true
27-
[tool.poetry.group.dev.dependencies]
28-
black = ">=23.3.0"
29-
ruff = ">=0.0.275"
30-
3125
[tool.poetry.group.test]
3226
optional = true
3327
[tool.poetry.group.test.dependencies]

run_checks.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)