Skip to content

Commit

Permalink
Add pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Sep 30, 2024
1 parent 9404e7a commit 5445261
Show file tree
Hide file tree
Showing 32 changed files with 259 additions and 219 deletions.
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.7
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class __ModuleName__Embeddings(Embeddings):
# TODO: Replace with relevant packages, env vars.
Setup:
Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.
Install ``__package_name__`` and set environment
variable ``__MODULE_NAME___API_KEY``.
.. code-block:: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class __ModuleName__LLM(BaseLLM):
# TODO: Replace with relevant packages, env vars.
Setup:
Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.
Install ``__package_name__`` and set environment
variable ``__MODULE_NAME___API_KEY``.
.. code-block:: bash
Expand All @@ -41,7 +42,8 @@ class __ModuleName__LLM(BaseLLM):
max_retries: int
Max number of retries.
api_key: Optional[str]
__ModuleName__ API key. If not passed in will be read from env var __MODULE_NAME___API_KEY.
__ModuleName__ API key. If not passed in will be read from
env var __MODULE_NAME___API_KEY.
See full list of supported init args and their descriptions in the params section.
Expand Down
11 changes: 5 additions & 6 deletions libs/partners/box/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ lint_tests: PYTHON_FILES=tests
lint_tests: MYPY_CACHE=.mypy_cache_test

lint lint_diff lint_package lint_tests:
poetry run ruff .
poetry run ruff format $(PYTHON_FILES) --diff
poetry run ruff --select I $(PYTHON_FILES)
mkdir -p $(MYPY_CACHE); poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)

format format_diff:
poetry run ruff format $(PYTHON_FILES)
poetry run ruff --select I --fix $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check --select I --fix $(PYTHON_FILES)

spell_check:
poetry run codespell --toml pyproject.toml
Expand Down
49 changes: 25 additions & 24 deletions libs/partners/box/poetry.lock

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

2 changes: 1 addition & 1 deletion libs/partners/box/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ python-dotenv = "^1.0.1"
optional = true

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.8"
ruff = "^0.5"

[tool.poetry.group.typing.dependencies]
mypy = "^1.7.1"
Expand Down
4 changes: 2 additions & 2 deletions libs/partners/milvus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ lint_tests: PYTHON_FILES=tests
lint_tests: MYPY_CACHE=.mypy_cache_test

lint lint_diff lint_package lint_tests:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)

format format_diff:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff --select I --fix $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check --select I --fix $(PYTHON_FILES)

spell_check:
poetry run codespell --toml pyproject.toml
Expand Down
68 changes: 43 additions & 25 deletions libs/partners/milvus/poetry.lock

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

4 changes: 2 additions & 2 deletions libs/partners/milvus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
repository = "https://github.com/langchain-ai/langchain"
license = "MIT"

[tool.ruff]
[tool.ruff.lint]
select = ["E", "F", "I", "T201"]

[tool.mypy]
Expand Down Expand Up @@ -96,7 +96,7 @@ codespell = "^2.2.0"
milvus_model = "^0.2.0"

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.5"
ruff = "^0.5"

[tool.poetry.group.typing.dependencies]
mypy = "^0.991"
Expand Down
4 changes: 2 additions & 2 deletions libs/partners/nomic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ lint_tests: PYTHON_FILES=tests
lint_tests: MYPY_CACHE=.mypy_cache_test

lint lint_diff lint_package lint_tests:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)

format format_diff:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff --select I --fix $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check --select I --fix $(PYTHON_FILES)

spell_check:
poetry run codespell --toml pyproject.toml
Expand Down
Loading

0 comments on commit 5445261

Please sign in to comment.