Skip to content

fix: update expected files to use modern union type syntax (str | None)#2709

Merged
koxudaxi merged 1 commit intomainfrom
fix/update-expected-files-to-modern-type-syntax
Dec 20, 2025
Merged

fix: update expected files to use modern union type syntax (str | None)#2709
koxudaxi merged 1 commit intomainfrom
fix/update-expected-files-to-modern-type-syntax

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Dec 20, 2025

Summary by CodeRabbit

  • Documentation

    • Updated code examples to reflect modern Python type annotation syntax using PEP 604 union types (str | None) instead of the older Optional[str] format.
  • Refactor

    • Modernized type annotations throughout generated models to use union type syntax, improving consistency with current Python best practices.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 20, 2025

Walkthrough

This pull request modernizes type annotations across documentation examples and test expected outputs, replacing the Optional[T] syntax with PEP 604 union syntax T | None. The Optional import is correspondingly removed from affected files. No runtime behavior or logic is altered.

Changes

Cohort / File(s) Summary
Documentation Examples
docs/cli-reference/field-customization.md, docs/cli-reference/general-options.md, docs/cli-reference/template-customization.md
Updated code example snippets: replaced Optional[str] with str | None in field annotations; removed Optional import from typing module
Test Expected Outputs
tests/data/expected/main_kr/custom_file_header/without_option.py, tests/data/expected/main_kr/custom_formatters_kwargs/output.py, tests/data/expected/main_kr/ignore_pyproject/without_option.py, tests/data/expected/main_kr/no_alias/without_option.py
Updated expected generated model classes: replaced Optional[T] with T | None for multiple fields across different test cases; removed now-unused Optional imports

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Homogeneous, repetitive pattern applied consistently across all files
  • No functional or logic changes; purely syntactic type annotation modernization
  • Low risk: straightforward replacements in documentation and test outputs only

Suggested labels

safe-to-fix

Suggested reviewers

  • ilovelinux

Poem

🐰 Optional types become union blues,
PEP 604's modern syntactic hues,
From typing imports we bid adieu,
str | None is the elegant new,
Docs and tests in sync anew! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: updating expected test files to use PEP 604 union type syntax (str | None) instead of Optional[T], which is supported across all file changes in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/update-expected-files-to-modern-type-syntax

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ecc458 and 6e38bfd.

📒 Files selected for processing (7)
  • docs/cli-reference/field-customization.md (1 hunks)
  • docs/cli-reference/general-options.md (1 hunks)
  • docs/cli-reference/template-customization.md (1 hunks)
  • tests/data/expected/main_kr/custom_file_header/without_option.py (1 hunks)
  • tests/data/expected/main_kr/custom_formatters_kwargs/output.py (1 hunks)
  • tests/data/expected/main_kr/ignore_pyproject/without_option.py (1 hunks)
  • tests/data/expected/main_kr/no_alias/without_option.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: py312-isort7 on Ubuntu
  • GitHub Check: py312-isort6 on Ubuntu
  • GitHub Check: py312-isort5 on Ubuntu
  • GitHub Check: 3.10 on Windows
  • GitHub Check: 3.12 on Windows
  • GitHub Check: 3.13 on Ubuntu
  • GitHub Check: 3.11 on Windows
  • GitHub Check: 3.13 on Windows
  • GitHub Check: benchmarks
  • GitHub Check: Analyze (python)
🔇 Additional comments (7)
tests/data/expected/main_kr/no_alias/without_option.py (1)

13-13: LGTM! Modern union type syntax applied correctly.

The update from Optional[str] to str | None follows PEP 604 union syntax and is semantically equivalent. The change is appropriate for the expected test output.

tests/data/expected/main_kr/custom_file_header/without_option.py (1)

13-13: LGTM! Consistent type annotation modernization.

The field annotation correctly uses the modern str | None syntax instead of Optional[str].

docs/cli-reference/general-options.md (1)

1668-1669: LGTM! Documentation example updated correctly.

The example output correctly demonstrates the modern union type syntax (str | None) in the generated code, consistent with the tool's updated output format.

tests/data/expected/main_kr/ignore_pyproject/without_option.py (1)

10-11: LGTM! Field annotations modernized correctly.

Both field type annotations properly use the str | None union syntax, consistent with PEP 604 and the broader modernization effort across test expectations.

docs/cli-reference/template-customization.md (1)

183-183: LGTM! Documentation reflects updated output format.

The example correctly shows the modern union type syntax in the generated code, keeping documentation aligned with the tool's current behavior.

tests/data/expected/main_kr/custom_formatters_kwargs/output.py (1)

11-13: LGTM! All field annotations modernized correctly.

The Pet class fields properly use the modern union type syntax for both int | None and str | None, demonstrating consistent application across different types.

docs/cli-reference/field-customization.md (1)

1894-1894: LGTM! Documentation example properly updated.

The field annotation correctly demonstrates the modern str | None syntax in the example output, maintaining consistency with the updated code generator behavior.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.34%. Comparing base (8ecc458) to head (6e38bfd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2709   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files          81       81           
  Lines       11535    11535           
  Branches     1387     1387           
=======================================
  Hits        11459    11459           
  Misses         45       45           
  Partials       31       31           
Flag Coverage Δ
unittests 99.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi merged commit fba4713 into main Dec 20, 2025
35 checks passed
@koxudaxi koxudaxi deleted the fix/update-expected-files-to-modern-type-syntax branch December 20, 2025 10:18
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 20, 2025

CodSpeed Performance Report

Merging #2709 will not alter performance

Comparing fix/update-expected-files-to-modern-type-syntax (6e38bfd) with main (8ecc458)

Summary

✅ 52 untouched
⏩ 10 skipped1

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant