Skip to content

Commit

Permalink
update pre-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 21, 2024
1 parent 053579b commit 3304fbe
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 36 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ jobs:
**/requirements*.txt
**/pyproject.toml
**/uv.lock
Makefile
- name: Install dependencies
run: uv sync --dev --all-extras
- name: Install dependencies and setup pre-commit
run: make install

- name: Run pre-commit
uses: pre-commit/action@v3.0.0
- name: Run linting and type checking
run: make lint typecheck
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
hooks:
- id: ruff-format
exclude: ^uv\.lock$
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: ^uv\.lock$
- repo: local
hooks:
- id: typecheck
Expand Down
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.DEFAULT_GOAL := all

.PHONY: .uv ## Check that uv is installed
.uv:
@uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'

.PHONY: .pre-commit ## Check that pre-commit is installed
.pre-commit: .uv
@uv run pre-commit -V || uv pip install pre-commit

.PHONY: install ## Install the package, dependencies, and pre-commit for local development
install: .uv
uv sync --frozen --dev --all-extras
uv pip install pre-commit
pre-commit install --install-hooks

.PHONY: rebuild-lockfiles ## Rebuild lockfiles from scratch, updating all dependencies
rebuild-lockfiles: .uv
uv lock --upgrade

.PHONY: format ## Auto-format python source files
format: .uv
uv run ruff format .
uv run ruff check --fix .

.PHONY: lint ## Lint python source files
lint: .uv
uv run ruff check .
uv run ruff format .

.PHONY: typecheck ## Run type checking
typecheck: .pre-commit
pre-commit run typecheck --all-files

.PHONY: all ## Run the standard set of checks performed in CI
all: lint typecheck

.PHONY: clean ## Clear local caches and build artifacts
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]'`
rm -f `find . -type f -name '*~'`
rm -f `find . -type f -name '.*~'`
rm -rf .cache
rm -rf .pytest_cache
rm -rf .ruff_cache
rm -rf htmlcov
rm -rf *.egg-info
rm -f .coverage
rm -f .coverage.*
rm -rf build
rm -rf dist

.PHONY: help ## Display this message
help:
@grep -E \
'^.PHONY: .*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'
6 changes: 2 additions & 4 deletions src/raggy/utilities/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ async def create_openai_embeddings(
input_: str,
timeout: int = 60,
model: str = raggy.settings.openai_embeddings_model,
) -> Embedding:
...
) -> Embedding: ...


@overload
async def create_openai_embeddings(
input_: list[str],
timeout: int = 60,
model: str = raggy.settings.openai_embeddings_model,
) -> list[Embedding]:
...
) -> list[Embedding]: ...


@retry(
Expand Down
30 changes: 10 additions & 20 deletions src/raggy/utilities/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@ class RaggyLogger(logging.Logger):
def __init__(self, name: str, level: int = logging.NOTSET) -> None:
super().__init__(name, level)

def debug_style(self, message: str, style: str | None = None) -> None:
...
def debug_style(self, message: str, style: str | None = None) -> None: ...

def info_style(self, message: str, style: str | None = None) -> None:
...
def info_style(self, message: str, style: str | None = None) -> None: ...

def warning_style(self, message: str, style: str | None = None) -> None:
...
def warning_style(self, message: str, style: str | None = None) -> None: ...

def error_style(self, message: str, style: str | None = None) -> None:
...
def error_style(self, message: str, style: str | None = None) -> None: ...

def critical_style(self, message: str, style: str | None = None) -> None:
...
def critical_style(self, message: str, style: str | None = None) -> None: ...

def debug_kv(
self,
Expand All @@ -39,8 +34,7 @@ def debug_kv(
key_style: str = "green",
value_style: str = "default on default",
delimiter: str = ": ",
) -> None:
...
) -> None: ...

def info_kv(
self,
Expand All @@ -49,8 +43,7 @@ def info_kv(
key_style: str = "blue",
value_style: str = "default on default",
delimiter: str = ": ",
) -> None:
...
) -> None: ...

def warning_kv(
self,
Expand All @@ -59,8 +52,7 @@ def warning_kv(
key_style: str = "yellow",
value_style: str = "default on default",
delimiter: str = ": ",
) -> None:
...
) -> None: ...

def error_kv(
self,
Expand All @@ -69,8 +61,7 @@ def error_kv(
key_style: str = "red",
value_style: str = "default on default",
delimiter: str = ": ",
) -> None:
...
) -> None: ...

def critical_kv(
self,
Expand All @@ -79,8 +70,7 @@ def critical_kv(
key_style: str = "red",
value_style: str = "default on default",
delimiter: str = ": ",
) -> None:
...
) -> None: ...


logging.setLoggerClass(RaggyLogger)
Expand Down

0 comments on commit 3304fbe

Please sign in to comment.