-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: formatting, linting, and schema code generation #1935
ISSUE: #1935 CHANGELOG: - [ ] Addresses error handling and parallelized formatting for toml files. - [ ] Configures the ruff formatter to use requested format. - [ ] Fixes snake_case for several Python variables. - [ ] Configures the schemas.py code generator to generate snake_case field names to avoid lint reports and wraps the actual name in Field() metadata. - [ ] Clean up some lint. - [ ] Removes go-vulncheck from the pre-commit hook while retaining it during pre-push (easy to skip this using `-f --no-verify`).
- Loading branch information
Showing
18 changed files
with
343 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Format all TOML files in the project. | ||
# | ||
# Copyright 2025 Google LLC | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
GIT_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
if command -v taplo >/dev/null 2>&1; then | ||
if [ ! -f "${GIT_ROOT}/py/taplo.toml" ]; then | ||
echo "error: config file not found at ${GIT_ROOT}/py/taplo.toml" | ||
exit 1 | ||
fi | ||
|
||
FORMATTER_COMMAND="taplo format --config ${GIT_ROOT}/py/taplo.toml" | ||
#if command -v rust-parallel >/dev/null 2>&1; then | ||
# FORMATTER_COMMAND="rust-parallel -j4 ${FORMATTER_COMMAND}" | ||
#fi | ||
|
||
if command -v fd >/dev/null 2>&1; then | ||
echo "Using fd" | ||
fd -e toml \ | ||
--exclude 'py/**/*.egg-info/**' \ | ||
--exclude 'py/**/.dist/**' \ | ||
--exclude 'py/**/.next/**' \ | ||
--exclude 'py/**/.output/**' \ | ||
--exclude 'py/**/.pytest_cache/**' \ | ||
--exclude 'py/**/.venv/**' \ | ||
--exclude 'py/**/__pycache__/**' \ | ||
--exclude 'py/**/build/**' \ | ||
--exclude 'py/**/develop-eggs/**' \ | ||
--exclude 'py/**/dist/**' \ | ||
--exclude 'py/**/eggs/**' \ | ||
--exclude 'py/**/node_modules/**' \ | ||
--exclude 'py/**/sdist/**' \ | ||
--exclude 'py/**/site/**' \ | ||
--exclude 'py/**/target/**' \ | ||
--exclude 'py/**/venv/**' \ | ||
--exclude 'py/**/wheels/**' | | ||
${FORMATTER_COMMAND} | ||
else | ||
echo "Using find" | ||
find "${GIT_ROOT}" -name "*.toml" \ | ||
! -path 'py/**/*.egg-info/**' \ | ||
! -path 'py/**/.dist/**' \ | ||
! -path 'py/**/.next/**' \ | ||
! -path 'py/**/.output/**' \ | ||
! -path 'py/**/.pytest_cache/**' \ | ||
! -path 'py/**/.venv/**' \ | ||
! -path 'py/**/__pycache__/**' \ | ||
! -path 'py/**/build/**' \ | ||
! -path 'py/**/develop-eggs/**' \ | ||
! -path 'py/**/dist/**' \ | ||
! -path 'py/**/eggs/**' \ | ||
! -path 'py/**/node_modules/**' \ | ||
! -path 'py/**/sdist/**' \ | ||
! -path 'py/**/site/**' \ | ||
! -path 'py/**/target/**' \ | ||
! -path 'py/**/venv/**' \ | ||
! -path 'py/**/wheels/**' \ | ||
-print0 | | ||
${FORMATTER_COMMAND} | ||
fi | ||
else | ||
echo "Please install taplo to use this script" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Format all TOML files in the project. | ||
# | ||
# Copyright 2025 Google LLC | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
GIT_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
taplo format --config "${GIT_ROOT}/py/taplo.toml" | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# Copyright 2025 Google LLC | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Callable | ||
from collections.abc import Callable | ||
|
||
from genkit.core.schemas import GenerateRequest, GenerateResponse | ||
|
||
ModelFn = Callable[[GenerateRequest], GenerateResponse] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.