Skip to content

fix: support PEP 604 unions in File/Path coercion target detection#2878

Merged
markphelps merged 4 commits intoreplicate:mainfrom
erayack:pep604-uniontype-input-coercion
Mar 28, 2026
Merged

fix: support PEP 604 unions in File/Path coercion target detection#2878
markphelps merged 4 commits intoreplicate:mainfrom
erayack:pep604-uniontype-input-coercion

Conversation

@erayack
Copy link
Copy Markdown
Contributor

@erayack erayack commented Mar 27, 2026

Follow-up to #2872.

Summary

  • Add PEP 604 union support in input coercion target detection by accepting both typing.Union and types.UnionType origins.
  • Keep existing merged behavior intact: only explicitly typed File/Path fields are coercion targets.
  • Reuse the current FieldClassification flow (no CoercionPlan reintroduction).

Cases covered

  • File | None
  • Path | None
  • list[File] | None
  • list[Path] | None

Tests

  • Extended ignored Rust/PyO3 module tests in crates/coglet-python/src/input.rs for the 4 PEP 604 cases.
  • Kept assertions ensuring str/list[str] are not treated as coercion targets.

Validation run

  • mise run fmt:rust
  • mise run lint:rust
  • cd crates && PYTHONHOME=/Users/erayack/.local/share/uv/python/cpython-3.10.18-macos-aarch64-none PYO3_PYTHON=python3.10 cargo test -p coglet-python

@erayack erayack requested a review from a team as a code owner March 27, 2026 17:22
Copy link
Copy Markdown
Contributor

@markphelps markphelps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks @erayack . I created #2882 which we can merge after your fix

@markphelps markphelps enabled auto-merge March 27, 2026 19:38
@markphelps markphelps disabled auto-merge March 28, 2026 00:51
@markphelps markphelps merged commit 6ccf980 into replicate:main Mar 28, 2026
36 of 59 checks passed
markphelps added a commit that referenced this pull request Mar 30, 2026
….com/replicate/cog into mp/fix/dict-list-output-schema-fixes

* 'mp/fix/dict-list-output-schema-fixes' of https://github.com/replicate/cog: (44 commits)
  bonk code reviews (#2892)
  fix: clarify env variable deny-list error message (#2813)
  fix: use atomic rename in setup_subprocess_double_fork test to prevent race condition (#2815)
  chore(deps): bump github.com/docker/cli (#2885)
  chore(deps): bump ureq from 3.2.0 to 3.3.0 in /crates (#2888)
  docs: fix HTTP discovery endpoint response to match Rust implementation (#2883)
  fix: support PEP 604 unions in File/Path coercion detection (#2878)
  fix: remove mise python venv config to silence warnings (#2879)
  refactor: extract homebrew tap into standalone reusable workflow (#2881)
  chore: 0.17.1 (#2877)
  review: replace string tags with FieldKind enum, add Debug derives, remove redundant test assertion (#2874)
  fix: app id in release workflow for homebrew tap (#2875)
  fix: don't coerce URL strings in str-typed inputs (regression #2868) (#2872)
  use GHCR mirror for cog-base images in integration tests (#2866)
  docs: improve documentation for input/output types (#2864)
  add workflow to mirror cog-base images from r8.im to GHCR (#2871)
  fix: bound fuzz tree size to prevent CI timeout in FuzzJSONSchema
  fix: guard against slice panic on single-char quoted strings in parseTypeFromString
  fix: address review issues in static schema generation
  Bump version to 0.17.0
  ...
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.

2 participants