mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
fix(mypy): add fast and full mypy modes
This commit is contained in:
parent
c9d4b6c54f
commit
3659c121f9
4 changed files with 56 additions and 15 deletions
16
.github/workflows/pre-commit.yml
vendored
16
.github/workflows/pre-commit.yml
vendored
|
|
@ -43,6 +43,9 @@ jobs:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: 'src/llama_stack/ui/'
|
cache-dependency-path: 'src/llama_stack/ui/'
|
||||||
|
|
||||||
|
- name: Set up uv
|
||||||
|
uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7.1.1
|
||||||
|
|
||||||
- name: Install npm dependencies
|
- name: Install npm dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: src/llama_stack/ui
|
working-directory: src/llama_stack/ui
|
||||||
|
|
@ -109,3 +112,16 @@ jobs:
|
||||||
echo "$unstaged_files"
|
echo "$unstaged_files"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Sync dev + type_checking dependencies
|
||||||
|
run: uv sync --group dev --group type_checking
|
||||||
|
|
||||||
|
- name: Run mypy (full type_checking)
|
||||||
|
run: |
|
||||||
|
set +e
|
||||||
|
uv run --group dev --group type_checking mypy
|
||||||
|
status=$?
|
||||||
|
if [ $status -ne 0 ]; then
|
||||||
|
echo "::error::Full mypy failed. Reproduce locally with 'uv run pre-commit run mypy-full --hook-stage manual --all-files'."
|
||||||
|
fi
|
||||||
|
exit $status
|
||||||
|
|
|
||||||
|
|
@ -57,17 +57,27 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: uv-lock
|
- id: uv-lock
|
||||||
|
|
||||||
- repo: local
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v1.18.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
name: mypy
|
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- uv==0.7.8
|
- uv==0.6.2
|
||||||
entry: uv run --group dev --group type_checking mypy
|
- pytest
|
||||||
language: python
|
- rich
|
||||||
types: [python]
|
- types-requests
|
||||||
|
- pydantic
|
||||||
|
- httpx
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
require_serial: true
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: mypy-full
|
||||||
|
name: mypy (full type_checking)
|
||||||
|
entry: uv run --group dev --group type_checking mypy
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
stages: [manual]
|
||||||
|
|
||||||
# - repo: https://github.com/tcort/markdown-link-check
|
# - repo: https://github.com/tcort/markdown-link-check
|
||||||
# rev: v3.11.2
|
# rev: v3.11.2
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,18 @@ uv run pre-commit run --all-files -v
|
||||||
|
|
||||||
The `-v` (verbose) parameter is optional but often helpful for getting more information about any issues with that the pre-commit checks identify.
|
The `-v` (verbose) parameter is optional but often helpful for getting more information about any issues with that the pre-commit checks identify.
|
||||||
|
|
||||||
|
To run the expanded mypy configuration that CI enforces, use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run pre-commit run mypy-full --hook-stage manual --all-files
|
||||||
|
```
|
||||||
|
|
||||||
|
or invoke mypy directly with all optional dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run --group dev --group type_checking mypy
|
||||||
|
```
|
||||||
|
|
||||||
```{caution}
|
```{caution}
|
||||||
Before pushing your changes, make sure that the pre-commit hooks have passed successfully.
|
Before pushing your changes, make sure that the pre-commit hooks have passed successfully.
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -995,7 +995,9 @@ class ChatAgent(ShieldRunnerMixin):
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
raise ValueError(f"Failed to parse arguments for tool call: {tool_call.arguments}") from e
|
raise ValueError(f"Failed to parse arguments for tool call: {tool_call.arguments}") from e
|
||||||
|
|
||||||
result = await self.tool_runtime_api.invoke_tool(
|
result = cast(
|
||||||
|
ToolInvocationResult,
|
||||||
|
await self.tool_runtime_api.invoke_tool(
|
||||||
tool_name=tool_name_str,
|
tool_name=tool_name_str,
|
||||||
kwargs={
|
kwargs={
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
|
|
@ -1003,6 +1005,7 @@ class ChatAgent(ShieldRunnerMixin):
|
||||||
**args,
|
**args,
|
||||||
**self.tool_name_to_args.get(tool_name_str, {}),
|
**self.tool_name_to_args.get(tool_name_str, {}),
|
||||||
},
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
logger.debug(f"tool call {tool_name_str} completed with result: {result}")
|
logger.debug(f"tool call {tool_name_str} completed with result: {result}")
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue