Skip to content

Add pre-commit #13

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2023
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file configures editors, IDEs, and prettier

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 88
indent_size = 4
indent_style = space

[*.{yml,yaml}]
indent_size = 2
22 changes: 12 additions & 10 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ jobs:
id: setup_py
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
python-version: "3.10"
cache: poetry

- name: Poetry install
run: |
poetry lock --check # check that lockfile is up to date
poetry install --with test,dev --extras annlibs
poetry install --with test --extras annlibs

- name: Run test suite
run: |
poetry run pytest -v --color=yes

- name: Run formatter
run: |
poetry run black --check .

- name: Run style checks
run: |
poetry run ruff .
check: # TODO: replace with pre-commit.ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- uses: pre-commit/[email protected]
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: check-merge-conflict
- id: detect-private-key
- id: no-commit-to-branch
args: ["--branch=main"]
- repo: https://github.com/psf/black
rev: "23.3.0"
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.275
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ reason is that currently the only neighbourhood algorithms which are
build into scikit-learn are essentially the standard tree approaches
to space partitioning: the ball tree and the K-D tree. These do not
perform competitively in high dimensional spaces.

Development
===========

This project is managed using Poetry_ and pre-commit_.
To get started, run ``pre-commit install`` once and ``poetry install ...``
whenever dependencies have changed. E.g. @flying-sheep runs::

poetry install --with=test --extras=annlibs

This installs all optional (dev) dependencies except for those to build the docs.
pre-commit_ comes into play on every `git commit` after installation.

Consult ``pyproject.toml`` for which dependency groups and extras exist,
and the poetry help or user guide for more info on what they are.

.. _poetry: https://python-poetry.org/
.. _pre-commit: https://pre-commit.com/
139 changes: 1 addition & 138 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ pynndescent = ["pynndescent"]
nmslib = ["nmslib"]
annlibs = ["annoy", "faiss-cpu", "pynndescent", "nmslib"]

[tool.poetry.group.dev]
optional = true
[tool.poetry.group.dev.dependencies]
black = ">=23.3.0"
ruff = ">=0.0.275"

[tool.poetry.group.test]
optional = true
[tool.poetry.group.test.dependencies]
Expand Down
5 changes: 0 additions & 5 deletions run_checks.sh

This file was deleted.