Skip to content

Use class-name-suffix for parser config TypedDicts#2888

Merged
koxudaxi merged 1 commit intomainfrom
feature/use-class-name-suffix-for-config-types
Jan 1, 2026
Merged

Use class-name-suffix for parser config TypedDicts#2888
koxudaxi merged 1 commit intomainfrom
feature/use-class-name-suffix-for-config-types

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Jan 1, 2026

Summary by CodeRabbit

  • Refactor
    • Updated naming conventions for internal parser configuration classes and introduced a new configuration parameter to customize generated class name suffixes.

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 1, 2026

📝 Walkthrough

Walkthrough

This PR renames parser configuration TypedDict classes to include a "Dict" suffix for consistency, updates corresponding base class relationships, refactors type imports to use new names directly, and adds a matching pyproject.toml configuration key.

Changes

Cohort / File(s) Summary
Configuration
pyproject.toml
Added class-name-suffix = "Dict" configuration key in [tool.datamodel-codegen.profiles.parser-config-dicts] profile.
Parser Configuration Types
src/datamodel_code_generator/_types/parser_config_dicts.py
Renamed TypedDict classes: ParserConfigParserConfigDict, GraphQLParserConfigGraphQLParserConfigDict, JSONSchemaParserConfigJSONSchemaParserConfigDict, OpenAPIParserConfigOpenAPIParserConfigDict. Updated base class relationships and renamed Model TypeAlias to ModelDict.
Type Exports
src/datamodel_code_generator/_types/__init__.py
Refactored imports to use direct references to Dict-suffixed public names instead of aliases; no public API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

breaking-change-analyzed

Poem

🐰 With whiskers twitched and careful care,
The Dict names now suffixed fair,
ParserConfig finds its Dict display,
Types organized in every way! ✨

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 accurately describes the main change: renaming parser config TypedDict classes to use a 'Dict' suffix, which aligns with the class-name-suffix configuration introduced in pyproject.toml.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 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 0c3b510 and d41b794.

📒 Files selected for processing (3)
  • pyproject.toml
  • src/datamodel_code_generator/_types/__init__.py
  • src/datamodel_code_generator/_types/parser_config_dicts.py
🧰 Additional context used
🧬 Code graph analysis (1)
src/datamodel_code_generator/_types/__init__.py (1)
src/datamodel_code_generator/_types/parser_config_dicts.py (4)
  • GraphQLParserConfigDict (152-154)
  • JSONSchemaParserConfigDict (157-158)
  • OpenAPIParserConfigDict (161-164)
  • ParserConfigDict (35-149)
⏰ 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). (12)
  • GitHub Check: 3.11 on Ubuntu
  • GitHub Check: py312-isort7 on Ubuntu
  • GitHub Check: 3.10 on Windows
  • GitHub Check: py312-isort5 on Ubuntu
  • GitHub Check: py312-pydantic1 on Ubuntu
  • GitHub Check: 3.13 on Ubuntu
  • GitHub Check: 3.11 on Windows
  • GitHub Check: 3.12 on Windows
  • GitHub Check: 3.13 on Windows
  • GitHub Check: 3.14 on Windows
  • GitHub Check: Analyze (python)
  • GitHub Check: benchmarks
🔇 Additional comments (5)
src/datamodel_code_generator/_types/__init__.py (1)

8-11: LGTM! Import refactoring is clean.

The imports now directly use the Dict-suffixed names, eliminating the need for import aliases. This is cleaner and consistent with the renamed TypedDict classes in parser_config_dicts.py.

pyproject.toml (1)

286-286: Configuration correctly specifies the Dict suffix.

The class-name-suffix = "Dict" setting properly instructs the code generator to append "Dict" to all generated TypedDict class names, resulting in the consistent naming convention seen in parser_config_dicts.py.

src/datamodel_code_generator/_types/parser_config_dicts.py (3)

35-35: Consistent renaming of base configuration TypedDict.

The ParserConfigDict name follows the established pattern and maintains the same TypedDict structure. All derived classes correctly inherit from this renamed base.


152-164: Inheritance relationships correctly maintained.

All derived TypedDict classes properly inherit from their Dict-suffixed base classes:

  • GraphQLParserConfigDict and JSONSchemaParserConfigDict both extend ParserConfigDict
  • OpenAPIParserConfigDict extends JSONSchemaParserConfigDict

The hierarchy is consistent and correct.


167-167: TypeAlias correctly references all four Dict-suffixed configuration types.

The ModelDict union is properly formed. This is an internal type alias only—it is not exported in the module's __all__, so no breaking API change is introduced by this refactoring.

Likely an incorrect or invalid review comment.


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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 1, 2026

📚 Docs Preview: https://pr-2888.datamodel-code-generator.pages.dev

Comment thread src/datamodel_code_generator/_types/parser_config_dicts.py Dismissed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jan 1, 2026

CodSpeed Performance Report

Merging #2888 will improve performance by 21.86%

Comparing feature/use-class-name-suffix-for-config-types (d41b794) with main (0c3b510)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

⚡ 11 improvements
⏩ 98 skipped1

Benchmarks breakdown

Mode Benchmark BASE HEAD Efficiency
WallTime test_perf_duplicate_names 999.8 ms 841.4 ms +18.82%
WallTime test_perf_large_models_pydantic_v2 3.6 s 3 s +20.28%
WallTime test_perf_complex_refs 2.1 s 1.7 s +21.86%
WallTime test_perf_deep_nested 6 s 5.1 s +18.14%
WallTime test_perf_openapi_large 2.9 s 2.5 s +18.07%
WallTime test_perf_graphql_style_pydantic_v2 811 ms 690.6 ms +17.43%
WallTime test_perf_kubernetes_style_pydantic_v2 2.6 s 2.2 s +19.45%
WallTime test_perf_multiple_files_input 3.7 s 3.1 s +18.94%
WallTime test_perf_aws_style_openapi_pydantic_v2 1.9 s 1.6 s +17.31%
WallTime test_perf_stripe_style_pydantic_v2 2 s 1.6 s +19.9%
WallTime test_perf_all_options_enabled 6.7 s 5.7 s +17.35%

Footnotes

  1. 98 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.37%. Comparing base (0c3b510) to head (d41b794).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2888   +/-   ##
=======================================
  Coverage   99.37%   99.37%           
=======================================
  Files          92       92           
  Lines       16121    16121           
  Branches     1898     1898           
=======================================
  Hits        16020    16020           
  Misses         52       52           
  Partials       49       49           
Flag Coverage Δ
unittests 99.37% <ø> (ø)

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 94bb621 into main Jan 1, 2026
39 checks passed
@koxudaxi koxudaxi deleted the feature/use-class-name-suffix-for-config-types branch January 1, 2026 15:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 1, 2026

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is a pure internal refactoring. The changes rename internal TypedDict classes in the auto-generated parser_config_dicts.py file from ParserConfigParserConfigDict, GraphQLParserConfigGraphQLParserConfigDict, etc. by adding a class-name-suffix = "Dict" config option. However, the public API exports (via __all__ in _types/__init__.py) remain unchanged - the same ParserConfigDict, GraphQLParserConfigDict, JSONSchemaParserConfigDict, and OpenAPIParserConfigDict names are still exported. Previously these were aliased at import time (ParserConfig as ParserConfigDict), now they're generated with the correct names directly. The ModelModelDict TypeAlias change is also internal-only and was never exported. Users importing these types see no change whatsoever.


This analysis was performed by Claude Code Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 2, 2026

🎉 Released in 0.52.0

This PR is now available in the latest release. See the release notes for details.

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.

2 participants