Skip to content

Conversation

@Zaczero
Copy link

@Zaczero Zaczero commented Dec 1, 2025

Support using SecretBytes type annotation with File() parameter, similar to how bytes is supported. This enables secure handling of data content that should not be logged or displayed. Also support NewType-wrapped variants of bytes and SecretBytes.

@YuriiMotov YuriiMotov added the feature New feature or request label Dec 1, 2025
@Zaczero Zaczero force-pushed the claude/add-secretbytes-file-support-01EPuVvRf5NgUBHVK1JNcBdw branch 3 times, most recently from 6772a5f to 76989bf Compare December 1, 2025 17:17
@Zaczero Zaczero marked this pull request as draft December 1, 2025 17:19
Support using SecretBytes type annotation with File() parameter, similar to
how bytes is supported. This enables secure handling of file content that
should not be logged or displayed.

Also add support for NewType wrappers around bytes and SecretBytes types
by unwrapping NewType in type detection functions.

- Add _unwrap_newtype() helper to handle NewType wrappers
- Update is_bytes_or_nonable_bytes_annotation() to check for SecretBytes
  (both pydantic.types.SecretBytes and pydantic.v1.types.SecretBytes)
- Update is_bytes_field() in v1.py for Pydantic v1 compatibility
- Add comprehensive tests for SecretBytes and NewType with File()

Supports: SecretBytes, SecretBytes | None, List[SecretBytes],
          NewType('X', bytes), NewType('X', SecretBytes)

Co-authored-by: Kamil Monicz <kamil@monicz.dev>
@Zaczero Zaczero force-pushed the claude/add-secretbytes-file-support-01EPuVvRf5NgUBHVK1JNcBdw branch from 76989bf to 03067fc Compare December 1, 2025 17:35
@Zaczero Zaczero changed the title Add SecretBytes support for File() parameter Add SecretBytes and NewType support for File() parameter Dec 1, 2025
@Zaczero Zaczero marked this pull request as ready for review December 1, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants