Title: fix(types): correct nullability of config fields in command TypedDicts by bearomorphism · Pull Request #1952 · commitizen-tools/commitizen · GitHub
Open Graph Title: fix(types): correct nullability of config fields in command TypedDicts by bearomorphism · Pull Request #1952 · commitizen-tools/commitizen
X Title: fix(types): correct nullability of config fields in command TypedDicts by bearomorphism · Pull Request #1952 · commitizen-tools/commitizen
Description: Description Several command TypedDicts declared fields as non-nullable (int, str, dict, list) while argparse produces None when CLI flags are omitted. Runtime code already handles None correctly (via or fallbacks, .get(), explicit None checks), but the type annotations were misleading to both developers and mypy. Changes CommitArgs: message_length_limit: int → int | None CheckArgs: message_length_limit: int → int | None, allowed_prefixes: list[str] → list[str] | None BumpArgs: file_name: str → str | None ChangelogArgs: file_name, start_rev, tag_format, version_scheme, export_template, template → add | None; extras → dict[str, Any] | None Scope Type annotations only — no behavioral changes. Audit findings A full audit of all Settings fields and command TypedDicts found these inconsistency patterns: 1. CLI args produce None but TypedDict says non-nullable (fixed in this PR) Field TypedDict CLI default message_length_limit int in CommitArgs, CheckArgs None (no argparse default) allowed_prefixes list[str] in CheckArgs None (nargs="*", no default) file_name str in BumpArgs, ChangelogArgs None (no default) start_rev, tag_format, version_scheme, export_template, template str in ChangelogArgs None extras dict[str, Any] in ChangelogArgs None (ParseKwargs action, no default) 2. <= 0 guard consistency for message_length_limit Both code paths correctly treat 0 and negatives as "no limit": commit.py:92-93: if message_length_limit is None or message_length_limit <= 0 check.py → base.py:133: if max_msg_length is not None and max_msg_length > 0 The None check in commit.py:93 was dead code to mypy (type said int). This PR makes it type-correct. The behavioral bug where arguments.get("key", fallback) returns None instead of falling through to config is tracked separately in #1899 / #1900. 3. Out of scope (no changes needed or separate concerns) Settings TypedDict itself: already total=False, so missing defaults aren't a type error Fields missing from DEFAULT_SETTINGS (annotated_tag, gpg_sign, change_type_map, style, customize, version_type): all accessed via .get() or guarded — no runtime risk BumpArgs(Settings) inheritance design: structural refactor tracked in #1672 / #1812 Config validation/coercion layer: base_config.py:49 does raw update() with no type checking — larger effort Related #1899 — the message_length_limit config-ignored bug (this PR makes the types accurate; the behavioral fix is in #1900) #1900 — behavioral fix for message_length_limit precedence (complementary, no conflict) #1812 — ChainMap-based settings refactor (complementary, no conflict) #1672 — tracking issue for the settings chain redesign Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-with: GitHub Copilot CLI following the guidelines Code Changes Add test cases to all the changes you introduce Run uv run poe all locally to ensure this change passes linter check and tests Manually test the changes Update the documentation for the changes No test or doc changes needed — this is a pure type annotation fix with no behavioral impact.
Open Graph Description: Description Several command TypedDicts declared fields as non-nullable (int, str, dict, list) while argparse produces None when CLI flags are omitted. Runtime code already handles None correctly (v...
X Description: Description Several command TypedDicts declared fields as non-nullable (int, str, dict, list) while argparse produces None when CLI flags are omitted. Runtime code already handles None correctly (v...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1952
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7d80f7f0-a31b-f40d-08b9-a4abc391ca0c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9360:1960:52D427C:74C5207:6A505D2F |
| html-safe-nonce | 78a53baca50f8338107feeda3bf2ef45d39a1d606e35ff66ba9e793ef820e168 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzYwOjE5NjA6NTJENDI3Qzo3NEM1MjA3OjZBNTA1RDJGIiwidmlzaXRvcl9pZCI6IjM0NzQ5NzI4NTQ1OTU5MDI3NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 539dc6c5992d1a5705997407de0309468e0023edba6b0c739c71b33401c232d2 |
| hovercard-subject-tag | pull_request:3648325122 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/commitizen-tools/commitizen/pull/1952/files |
| twitter:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| og:image:alt | Description Several command TypedDicts declared fields as non-nullable (int, str, dict, list) while argparse produces None when CLI flags are omitted. Runtime code already handles None correctly (v... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width