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
16 changes: 9 additions & 7 deletions .github/workflows/lint_custom_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ jobs:
with:
python-version: '3.12'

- name: Install ruff
run: pip install ruff
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1

- name: Lint with ruff
# No need to lint the automatically generated Speakeasy code
- name: Install dependencies
run: |
ruff check examples/
ruff check src/mistralai/_hooks/ --exclude __init__.py --exclude sdkhooks.py --exclude types.py
ruff check src/mistralai/extra/
touch README-PYPI.md
poetry install

# The init, sdkhooks.py and types.py files in the _hooks folders are generated by Speakeasy hence the exclusion
- name: Run all linters
run: scripts/lint_custom_code.sh
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.10
hooks:
- id: ruff
args: [--fix]
files: ^(example/|src/mistralai/).*\.py$
exclude: ^src/mistralai/(__init__|sdkhooks|types)\.py$
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.401
hooks:
- id: pyright
files: ^(example/|src/mistralai/).*\.py$
exclude: ^src/mistralai/(__init__|sdkhooks|types)\.py$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
files: ^(example/|src/mistralai/).*\.py$
exclude: ^src/mistralai/(__init__|sdkhooks|types)\.py$
147 changes: 101 additions & 46 deletions poetry.lock

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

8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ include = ["py.typed", "src/mistralai/py.typed"]
in-project = true

[tool.poetry.group.dev.dependencies]
mypy = "==1.14.1"
mypy = "==1.15.0"
pylint = "==3.2.3"
pytest = "^8.2.2"
pytest-asyncio = "^0.23.7"
types-python-dateutil = "^2.9.0.20240316"

[tool.poetry.group.lint.dependencies]
ruff = "^0.11.10"
pyright = "^1.1.401"
mypy = "==1.15.0"


[project.optional-dependencies]
gcp = [
"google-auth >=2.27.0",
Expand Down
31 changes: 31 additions & 0 deletions scripts/lint_custom_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -e

ERRORS=0

echo "Running mypy..."
# TODO: Uncomment once the examples are fixed
# poetry run mypy examples/ || ERRORS=1
poetry run mypy src/mistralai/extra/ || ERRORS=1
poetry run mypy src/mistralai/_hooks/ \
--exclude __init__.py --exclude sdkhooks.py --exclude types.py || ERRORS=1

echo "Running pyright..."
# TODO: Uncomment once the examples are fixed
# poetry run pyright examples/ || ERRORS=1
poetry run pyright src/mistralai/extra/ || ERRORS=1
poetry run pyright src/mistralai/_hooks/ || ERRORS=1

echo "Running ruff..."
poetry run ruff check examples/ || ERRORS=1
poetry run ruff check src/mistralai/extra/ || ERRORS=1
poetry run ruff check src/mistralai/_hooks/ \
--exclude __init__.py --exclude sdkhooks.py --exclude types.py || ERRORS=1

if [ "$ERRORS" -ne 0 ]; then
echo "❌ One or more linters failed"
exit 1
else
echo "✅ All linters passed"
fi
Loading
Loading