Skip to content

fix(types): correct nullability of config fields in command TypedDicts#1952

Open
bearomorphism wants to merge 1 commit intomasterfrom
fix/config-nullability-types
Open

fix(types): correct nullability of config fields in command TypedDicts#1952
bearomorphism wants to merge 1 commit intomasterfrom
fix/config-nullability-types

Conversation

@bearomorphism
Copy link
Copy Markdown
Collaborator

@bearomorphism bearomorphism commented May 8, 2026

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: intint | None
  • CheckArgs: message_length_limit: intint | None, allowed_prefixes: list[str]list[str] | None
  • BumpArgs: file_name: strstr | None
  • ChangelogArgs: file_name, start_rev, tag_format, version_scheme, export_template, template → add | None; extrasdict[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.pybase.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)

Related

Checklist

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.

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, but the type annotations
were misleading.

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 str -> str | None;
  extras dict[str, Any] -> dict[str, Any] | None

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (4b93a50) to head (bef33f7).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1952   +/-   ##
=======================================
  Coverage   98.23%   98.23%           
=======================================
  Files          61       61           
  Lines        2779     2779           
=======================================
  Hits         2730     2730           
  Misses         49       49           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bearomorphism bearomorphism marked this pull request as ready for review May 9, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant