Skip to content
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
20 changes: 2 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,9 @@ jobs:
poetry run pip install pydantic==${{ matrix.pydantic-version }}
poetry run pip install openai==${{ matrix.openai-version }}

- if: matrix.pydantic-version == '2.4.2' && matrix.openai-version == '0.28.1'
name: Static analysis with pyright (ignoring pydantic v1 and openai v1)
- name: Static analysis with pyright
run: |
make type-pydantic-v2-openai-v0

- if: matrix.pydantic-version == '1.10.9' && matrix.openai-version == '0.28.1'
name: Static analysis with mypy (ignoring pydantic v2 and openai v1)
run: |
make type-pydantic-v1-openai-v0

- if: matrix.pydantic-version == '2.4.2' && matrix.openai-version == '1.2.4'
name: Static analysis with pyright (ignoring pydantic v1 and openai v0)
run: |
make type-pydantic-v2-openai-v1

- if: matrix.pydantic-version == '1.10.9' && matrix.openai-version == '1.2.4'
name: Static analysis with mypy (ignoring pydantic v2 and openai v0)
run: |
make type-pydantic-v1-openai-v1
make type

Pytests:
runs-on: LargeBois
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Follow these steps before committing your changes:

1. Ensure tests pass: `make test`
2. Format your code: `make autoformat`
3. Update documentation if needed. Docs are located in the `docs` directory. You can serve docs using `mkdocs serve`.
3. Run static analysis: `make type`
4. Update documentation if needed. Docs are located in the `docs` directory. You can serve docs using `mkdocs serve`.

### Optional: Pre-Commit Hooks

Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
MKDOCS_SERVE_ADDR ?= localhost:8000 # Default address for mkdocs serve, format: <host>:<port>, override with `make docs-serve MKDOCS_SERVE_ADDR=<host>:<port>`

# Extract major package versions for OpenAI and Pydantic
OPENAI_VERSION_MAJOR := $(shell poetry run python -c 'import openai; print(openai.__version__.split(".")[0])')
PYDANTIC_VERSION_MAJOR := $(shell poetry run python -c 'import pydantic; print(pydantic.__version__.split(".")[0])')

# Construct the typing command using only major versions
TYPING_CMD := type-pydantic-v$(PYDANTIC_VERSION_MAJOR)-openai-v$(OPENAI_VERSION_MAJOR)

autoformat:
poetry run black guardrails/ tests/
poetry run isort --atomic guardrails/ tests/
poetry run docformatter --in-place --recursive guardrails tests

.PHONY: type
type:
poetry run pyright guardrails/
@make $(TYPING_CMD)

type-pydantic-v1-openai-v0:
echo '{"exclude": ["guardrails/utils/pydantic_utils/v2.py", "guardrails/utils/openai_utils/v1.py"]}' > pyrightconfig.json
Expand Down