Title: Consider accepting both snake_case and camelCase values for dicts and Literals · Issue #756 · apify/apify-client-python · GitHub
Open Graph Title: Consider accepting both snake_case and camelCase values for dicts and Literals · Issue #756 · apify/apify-client-python
X Title: Consider accepting both snake_case and camelCase values for dicts and Literals · Issue #756 · apify/apify-client-python
Description: Context Spun out of a review discussion on #738: #738 (comment) I think there is a case for accepting camelCase here instead - it is exactly what the API accepts. On the other hand, snake_case fits in better with the rest of the Python c...
Open Graph Description: Context Spun out of a review discussion on #738: #738 (comment) I think there is a case for accepting camelCase here instead - it is exactly what the API accepts. On the other hand, snake_case fits...
X Description: Context Spun out of a review discussion on #738: #738 (comment) I think there is a case for accepting camelCase here instead - it is exactly what the API accepts. On the other hand, snake_case fits...
Opengraph URL: https://github.com/apify/apify-client-python/issues/756
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consider accepting both snake_case and camelCase values for dicts and Literals","articleBody":"## Context\n\nSpun out of a review discussion on #738: https://github.com/apify/apify-client-python/pull/738#discussion_r3111857207\n\n> I think there is a case for accepting camelCase here instead - it is exactly what the API accepts. On the other hand, snake_case fits in better with the rest of the Python code and works better for the \"I just don't want to look up what model I need to import\" use case for TypedDicts.\n\nThe same tension already exists today for `Literal` values used in resource-client methods, e.g.:\n\n```python\nsort_by: Literal['created_at', 'last_run_started_at'] | None = 'created_at'\n```\n\nThe Apify API expects these as camelCase (`createdAt`, `lastRunStartedAt`), while the Python client exposes them in snake_case to match Python conventions. The same question now arises for the newly generated input-side `TypedDict`s from #738 (field names in dicts passed to client methods).\n\n## Proposal\n\nConsider — and, if agreed, implement — accepting **both** `snake_case` and `camelCase` values in:\n\n1. **`TypedDict` inputs** introduced in #738 (`_typeddicts_generated.py`, `_typeddicts.py`) — allow users to pass either naming style as keys.\n2. **`Literal` arguments** already present across resource clients (e.g. `sort_by`, pricing-model literals, webhook event-type literals, etc.) — accept both forms.\n\n### Trade-offs to weigh\n\n- **Pro snake_case only:** consistent with Pydantic models and the rest of the Python code; idiomatic for Python users.\n- **Pro camelCase only:** matches the API 1:1 — users who already know the API don't need a translation table, which is especially valuable for the \"I don't want to import the Pydantic model, just pass a dict\" use case.\n- **Pro accepting both:** maximum ergonomics, no wrong answer for the user; cost is implementation complexity (normalization layer) and documentation/typing clarity (both forms must be reflected in the type hints so the type checker accepts them).\n\n## Scope\n\n- Decide on the policy (one style only vs. both accepted).\n- If accepting both: define normalization boundary (input translation to API payload), update generation scripts (`scripts/postprocess_generated_models.py`) and the hand-written literals in resource clients, and ensure type checkers (`ty`) see both forms.\n- Update docs/examples accordingly.\n\ncc @janbuchar","author":{"url":"https://github.com/vdusek","@type":"Person","name":"vdusek"},"datePublished":"2026-04-23T09:57:46Z","url":"https://github.com/apify/apify-client-python/issues/756"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b942d07a-3bf7-d12b-34ee-5659db6811b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 818C:2A4B31:9A74AE:CFA4FD:6B0046C6 |
| html-safe-nonce | a554b1f72658f6f635f850e0cc1ef47c9d3f359c7a4ee18f5e697e874ac81434 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MThDOjJBNEIzMTo5QTc0QUU6Q0ZBNEZEOjZCMDA0NkM2IiwidmlzaXRvcl9pZCI6IjM3MjIyMDA5OTgwMjcxMTc1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8f1ac5ebc9dc394cdf0a31ff9c5d8457aefd448696fc82dc27249921a5afecc4 |
| hovercard-subject-tag | issue:4315107234 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apify/apify-client-python/756/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5077cfe496dcbee17f815b056f5ec61ab62c0a7ce220a1fdc8b1f1089d116cb/apify/apify-client-python/issues/756 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5077cfe496dcbee17f815b056f5ec61ab62c0a7ce220a1fdc8b1f1089d116cb/apify/apify-client-python/issues/756 |
| og:image:alt | Context Spun out of a review discussion on #738: #738 (comment) I think there is a case for accepting camelCase here instead - it is exactly what the API accepts. On the other hand, snake_case fits... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vdusek |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/apify/apify-client-python git https://github.com/apify/apify-client-python.git |
| octolytics-dimension-user_id | 24586296 |
| octolytics-dimension-user_login | apify |
| octolytics-dimension-repository_id | 164647835 |
| octolytics-dimension-repository_nwo | apify/apify-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 164647835 |
| octolytics-dimension-repository_network_root_nwo | apify/apify-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width