Skip to content
Open
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
16 changes: 11 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ __pycache__/
*.py[cod]
*$py.class
.pytest_cache/
..mypy_cache/
.mypy_cache/

# poetry
.venv
venv

# C extensions
*.so

# Virtual environment
.venv
venv
# Build artifacts
dist/
build/
*.egg-info/

# Test coverage
htmlcov/
.coverage
.coverage.*

.DS_Store
.AppleDouble
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
max-line-length = 88
max-line-length = 120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for line-length/max-line configurations in common config files

echo "=== Searching for line-length configurations ==="
rg -n "line.?length|max.?line" --type=toml --type=ini --type=yaml --type=cfg 2>/dev/null | head -50

echo -e "\n=== Checking pyproject.toml for formatter settings ==="
fd -t f "pyproject.toml" -x cat {} 2>/dev/null

echo -e "\n=== Checking setup.cfg for flake8/formatter settings ==="
fd -t f "setup.cfg" -x cat {} 2>/dev/null

echo -e "\n=== Checking .flake8 file ==="
cat .flake8 2>/dev/null || echo "File not found"

echo -e "\n=== Checking for tox.ini ==="
fd -t f "tox.ini" -x cat {} 2>/dev/null

Repository: qualifire-dev/qualifire-python-sdk

Length of output: 3946


Fix configuration mismatch between flake8 and Black/isort.

The .flake8 change to max-line-length = 120 conflicts with pyproject.toml which configures Black and isort to line-length = 88. Update either:

  • Black and isort in pyproject.toml to line-length = 120, or
  • .flake8 back to max-line-length = 88

Without this alignment, you'll have inconsistent line-length enforcement between formatting and linting.

🤖 Prompt for AI Agents
In @.flake8 at line 2, The flake8 max-line-length (max-line-length = 120 in
.flake8) conflicts with Black/isort's line-length in pyproject.toml (currently
88); fix by making them consistent: either change .flake8 max-line-length to 88,
or update pyproject.toml's [tool.black] and [tool.isort] line-length settings to
120 so all three (max-line-length, tool.black.line-length,
tool.isort.line_length) match; update only the setting(s) and run the
formatter/linter to verify no remaining mismatches.

exclude =
.git,
__pycache__,
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for TruffleHog to scan commits
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.7.0
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 1.6.1
version: "0.9.22"

- name: Install dependencies
run: |
poetry install
pip install pytest
pip install openai
uv sync
uv pip install pytest openai

- name: Run style checks
run: |
make check-codestyle

- name: Creadentials search in source code - TruffleHog OSS
uses: trufflesecurity/trufflehog@v3.69.0
Comment on lines 35 to 36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in step name.

"Creadentials" should be "Credentials".

📝 Proposed fix
-      - name: Creadentials search in source code - TruffleHog OSS
+      - name: Credentials search in source code - TruffleHog OSS
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Creadentials search in source code - TruffleHog OSS
uses: trufflesecurity/trufflehog@v3.69.0
- name: Credentials search in source code - TruffleHog OSS
uses: trufflesecurity/trufflehog@v3.69.0
🤖 Prompt for AI Agents
In @.github/workflows/build.yml around lines 33 - 34, Fix the misspelled GitHub
Actions step name by replacing "Creadentials search in source code - TruffleHog
OSS" with "Credentials search in source code - TruffleHog OSS" in the workflow
step that uses trufflesecurity/trufflehog@v3.69.0 so the step name reads
correctly.


- name: Run tests
run: |
make test
21 changes: 10 additions & 11 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v4.7.0
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build setuptools wheel twine
- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 1.6.1
version: "0.9.22"

- name: Build package
run: |
python -m build
uv build
# Verify the wheel is valid
twine check dist/*
uv tool run twine check dist/*

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ target/
# pyenv
.python-version

# poetry
.venv

# pipenv
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ repos:
hooks:
- id: isort
name: isort
entry: poetry run isort --settings-path pyproject.toml
entry: uv tool run isort --settings-path pyproject.toml
types: [python]
language: system

- repo: local
hooks:
- id: black
name: black
entry: poetry run black --config pyproject.toml
entry: uv tool run black --config pyproject.toml
types: [python]
language: system
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ make pre-commit-install
make test

# Run a single test file
poetry run pytest tests/test_types.py
uv run pytest tests/test_types.py

# Run a specific test
poetry run pytest tests/test_types.py::TestEvaluationRequest::test_validate_messages_input_output -v
uv run pytest tests/test_types.py::TestEvaluationRequest::test_validate_messages_input_output -v

# Format code (isort, black, pyupgrade)
make codestyle
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Dependencies

We use `poetry` to manage the [dependencies](https://github.com/python-poetry/poetry).
If you dont have `poetry`, you should install with `make poetry-download`.
We use `uv` to manage the [dependencies](https://docs.astral.sh/uv/).
If you dont have `uv`, you should install with `make uv-download` or follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
Comment on lines +5 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor typo: "dont" → "don't".

Proposed fix
-If you dont have `uv`, you should install with `make uv-download` or follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
+If you don't have `uv`, you should install with `make uv-download` or follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
We use `uv` to manage the [dependencies](https://docs.astral.sh/uv/).
If you dont have `uv`, you should install with `make uv-download` or follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
We use `uv` to manage the [dependencies](https://docs.astral.sh/uv/).
If you don't have `uv`, you should install with `make uv-download` or follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
🤖 Prompt for AI Agents
In `@CONTRIBUTING.md` around lines 5 - 6, Update the CONTRIBUTING.md sentence that
reads "If you dont have `uv`, you should install..." to correct the typo by
replacing "dont" with "don't" so the sentence reads "If you don't have `uv`, you
should install..."—locate this exact sentence in CONTRIBUTING.md and apply the
single-word fix.


To install dependencies and prepare [`pre-commit`](https://pre-commit.com/) hooks you would need to run `install` command:

Expand All @@ -12,7 +12,7 @@ make install
make pre-commit-install
```

To activate your `virtualenv` run `poetry shell`.
To activate your virtual environment, uv will automatically handle it when running commands with `uv run`.

## Codestyle

Expand Down
63 changes: 35 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,60 @@ PYTHONPATH := `pwd`
IMAGE := qualifire
VERSION := latest

#* Poetry
.PHONY: poetry-download
poetry-download:
pip install -U poetry==1.2.0
poetry --version

.PHONY: poetry-remove
poetry-remove:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) - --uninstall
#* UV
.PHONY: uv-download
uv-download:
brew install uv
uv --version

#* Installation
.PHONY: install
install:
poetry lock -n && poetry export --without-hashes > requirements.txt
poetry install -n
-poetry run mypy --install-types --non-interactive ./
uv sync
-uv run mypy --install-types --non-interactive ./

.PHONY: pre-commit-install
pre-commit-install:
poetry run pre-commit install
uv run pre-commit install

#* Formatters
.PHONY: codestyle
codestyle:
poetry run pyupgrade --exit-zero-even-if-changed --py38-plus **/*.py
poetry run isort --settings-path pyproject.toml ./
poetry run black --config pyproject.toml ./
uv run pyupgrade --exit-zero-even-if-changed --py38-plus **/*.py
uv run isort --settings-path pyproject.toml ./
uv run black --config pyproject.toml ./

.PHONY: formatting
formatting: codestyle

#* Linting
.PHONY: test
test:
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=qualifire tests/
poetry run coverage-badge -o assets/images/coverage.svg -f
PYTHONPATH=$(PYTHONPATH) uv run pytest -c pyproject.toml --cov-report=html --cov=qualifire tests/
uv run coverage-badge -o assets/images/coverage.svg -f

.PHONY: check-codestyle
check-codestyle:
poetry run isort --diff --check-only --settings-path pyproject.toml ./
poetry run black --diff --check --config pyproject.toml ./
poetry run darglint --verbosity 2 qualifire tests
uv run isort --diff --check-only --settings-path pyproject.toml ./
uv run black --diff --check --config pyproject.toml ./
uv run darglint --verbosity 2 qualifire tests

.PHONY: mypy
mypy:
poetry run mypy --config-file pyproject.toml ./
uv run mypy --config-file pyproject.toml ./

.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report
poetry run bandit -ll --skip B113 --recursive qualifire tests
uv run safety check --full-report
uv run bandit -ll --skip B113 --recursive qualifire tests

.PHONY: lint
lint: test check-codestyle mypy check-safety

.PHONY: update-dev-deps
update-dev-deps:
poetry add -D bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-html@latest pytest-cov@latest
poetry add -D --allow-prereleases black@latest
uv add --dev bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-html@latest pytest-cov@latest
uv add --dev --prerelease=allow black@latest

#* Docker
# Example: make docker-build VERSION=latest
Expand Down Expand Up @@ -108,7 +102,20 @@ pytestcache-remove:

.PHONY: build-remove
build-remove:
rm -rf build/
rm -rf build/ dist/

.PHONY: cleanup
cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove

#* Build
.PHONY: build
build:
uv build

.PHONY: build-wheel
build-wheel:
uv build --wheel

.PHONY: build-sdist
build-sdist:
uv build --sdist
36 changes: 18 additions & 18 deletions assets/images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 13 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ FROM python:3.11-slim-buster

ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
PATH="${PATH}:/root/.poetry/bin"
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.9.22 /uv /bin/

COPY pyproject.toml ./
WORKDIR /app

# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
COPY pyproject.toml uv.lock README.md ./

# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
RUN if [ "$INSTALL_DEV" = "true" ] ; then \
uv sync --frozen --no-cache ; \
else \
uv sync --frozen --no-cache --no-dev ; \
fi

CMD mkdir -p /workspace
WORKDIR /workspace
COPY . .

CMD ["/bin/bash"]
16 changes: 15 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,28 @@ Default version is `VERSION := latest`.
make docker-build IMAGE=some_name VERSION=0.1.0
```

### Build with dev dependencies

To build with development dependencies (for testing):

```bash
docker build --build-arg INSTALL_DEV=true -t qualifire:dev -f docker/Dockerfile .
```

## Usage

```bash
docker run -it --rm \
-v $(pwd):/workspace \
-v $(pwd):/app/workspace \
qualifire bash
```

Run tests inside the container:

```bash
docker run -it --rm qualifire:dev uv run pytest
```

## How to clean up

To uninstall docker image run `make docker-remove` with `VERSION`:
Expand Down
Loading