Skip to content

refactor(py): remove files_before_body config and unify single-file guard#65

Merged
chyroc merged 2 commits into
mainfrom
refactor/remove-files-before-body-config
Feb 26, 2026
Merged

refactor(py): remove files_before_body config and unify single-file guard#65
chyroc merged 2 commits into
mainfrom
refactor/remove-files-before-body-config

Conversation

@chyroc

@chyroc chyroc commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove files_before_body from OperationMapping config schema
  • simplify Python operation renderer to always render files assignment after body preparation
  • remove all files_before_body entries from config/generator.yaml
  • optimize single-file upload rendering: always use guarded assignment (if file else {}) for consistent behavior across required/optional file fields
  • update renderer test coverage to assert the new fixed ordering and unified file guard expression

Validation

  • ./scripts/fmt.sh
  • ./scripts/lint.sh
  • ./scripts/test.sh (coverage: 83.2%)
  • ./scripts/build.sh

Downstream PR

@chyroc chyroc changed the title refactor(py): remove files_before_body config support refactor(py): remove files_before_body config and unify single-file guard Feb 26, 2026
@chyroc chyroc merged commit 5db2f95 into main Feb 26, 2026
6 checks passed
chyroc added a commit to coze-dev/coze-py that referenced this pull request Feb 26, 2026
## Summary
- sync generated Python SDK output after upstream optimization in
`coze-sdk-gen` for single-file upload rendering
- unify all single-file upload assignments to:
  - `files = {"file": _try_fix_file(file)} if file else {}`
- this removes the previous inconsistency where required file fields
used unconditional assignment while optional file fields used
conditional assignment

## Generator change
- upstream generator PR:
coze-dev/coze-sdk-gen#65

## Changed SDK files
- cozepy/audio/transcriptions/__init__.py
- cozepy/audio/voices/__init__.py
- cozepy/audio/voiceprint_groups/__init__.py
- cozepy/audio/voiceprint_groups/features/__init__.py

## Validation
- from coze-sdk-gen repo:
  - ./scripts/genpy.sh --output-sdk exist-repo/coze-py --ci-check
- coze-py checks passed in ci-check:
  - poetry build
  - poetry run ruff check cozepy
  - poetry run ruff format --check
  - poetry run mypy .
  - poetry run pytest --cov --cov-report=xml


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Adjusted multipart handling across voiceprint groups, audio features,
transcriptions, and voice clone operations to include file data only
when a file is provided, reducing unnecessary payloads.
* **Chore**
  * Minor internal cleanup improving request construction consistency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant