SIGN IN SIGN UP

fix: relax enum validation to tolerate unknown API values (#941)

Enum fields in the generated models were strict `Literal[...]` aliases
in `_literals.py`. Because every API response is Pydantic-validated, any
unknown or newly introduced enum value the platform sent raised a
`ValidationError` and broke the whole call.

The postprocess step now emits an open literal `Literal[...] | str` for
each shared enum alias, so unknown values validate while the known
members stay as autocomplete hints. Discriminated unions are unaffected
— they use inline single-value `Literal[...]`, not the shared aliases.

Changes:

- `scripts/postprocess_generated_models.py`: emit `Literal[...] | str`;
broaden the literal-alias detection (`_is_literal_expr`) so a widened
alias is still recognized and moved into `_literals.py`.
- `src/apify_client/_literals.py`: regenerated — all 11 aliases widened
(members unchanged).
- `pyproject.toml`: ignore `PYI051` for `_literals.py` (the
redundant-looking `Literal[...] | str` union is deliberate).
- `tests/unit/test_postprocess_generated_models.py`: cover the open
union end-to-end, plus a negative case for non-`str` unions.

Closes #931
V
Vlada Dusek committed
587baa77e023d7ba925a7d4eecaff58da3b55237
Parent: 1b0290a
Committed by GitHub <noreply@github.com> on 7/10/2026, 9:39:01 AM