Skip to content

Consolidate ParserConfig TypedDict profiles with inheritance preservation#2883

Merged
koxudaxi merged 1 commit intomainfrom
refactor/consolidate-parser-config-profiles
Dec 31, 2025
Merged

Consolidate ParserConfig TypedDict profiles with inheritance preservation#2883
koxudaxi merged 1 commit intomainfrom
refactor/consolidate-parser-config-profiles

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Dec 31, 2025

Summary by CodeRabbit

  • Refactor
    • Consolidated multiple configuration profiles into unified structures for improved project organization and maintainability
    • Reorganized build configuration files to use streamlined declarations and reduce redundancy across the codebase
    • Simplified internal type module organization and definitions while preserving compatibility and existing functionality

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

The PR consolidates four separate parser configuration TypedDict declarations from multiple files into a single unified parser_config_dicts.py module, updates build configuration profiles to reference the consolidated definitions, and revises public API exports accordingly.

Changes

Cohort / File(s) Summary
Build configuration consolidation
.pre-commit-config.yaml, pyproject.toml, tox.ini
Merged four separate datamodel-codegen profiles (parser-config-dict, graphql-parser-config-dict, jsonschema-parser-config-dict, openapi-parser-config-dict) into a single parser-config-dicts profile; updated input-model references to include all four config types in one list and output to consolidated parser_config_dicts.py
Removed parser config modules
src/datamodel_code_generator/_types/graphql_parser_config_dict.py, src/datamodel_code_generator/_types/jsonschema_parser_config_dict.py, src/datamodel_code_generator/_types/parser_config_dict.py
Deleted individual TypedDict files containing ParserConfig, GraphQLParserConfigDict, JSONSchemaParserConfigDict, and ParserConfigDict declarations
Consolidated parser config module
src/datamodel_code_generator/_types/parser_config_dicts.py
Created new unified module combining all parser configuration types; introduced GraphQLParserConfig class extending ParserConfig with data_model_scalar_type and data_model_union_type fields; renamed OpenAPIParserConfigDict to OpenAPIParserConfig; added Model TypeAlias representing union of all parser config types
Public API update
src/datamodel_code_generator/_types/__init__.py
Updated imports to source all parser config types from consolidated parser_config_dicts module; added GraphQLParserConfigDict, JSONSchemaParserConfigDict, OpenAPIParserConfigDict, and ParserConfigDict to all exports with aliasing from renamed base types

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

breaking-change-analyzed

Poem

🐰 Four scattered configs, now joined as one,
Consolidated wisdom beneath the sun.
Parser types bundled with grace and care,
A unified structure, consolidated and fair! ✨

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: consolidating multiple ParserConfig TypedDict profiles into a unified structure while maintaining inheritance relationships.
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 20ad1a1 and 319ee8a.

📒 Files selected for processing (8)
  • .pre-commit-config.yaml
  • pyproject.toml
  • src/datamodel_code_generator/_types/__init__.py
  • src/datamodel_code_generator/_types/graphql_parser_config_dict.py
  • src/datamodel_code_generator/_types/jsonschema_parser_config_dict.py
  • src/datamodel_code_generator/_types/parser_config_dict.py
  • src/datamodel_code_generator/_types/parser_config_dicts.py
  • tox.ini
💤 Files with no reviewable changes (3)
  • src/datamodel_code_generator/_types/parser_config_dict.py
  • src/datamodel_code_generator/_types/jsonschema_parser_config_dict.py
  • src/datamodel_code_generator/_types/graphql_parser_config_dict.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/datamodel_code_generator/_types/__init__.py (2)
src/datamodel_code_generator/_types/parser_config_dicts.py (4)
  • GraphQLParserConfig (148-150)
  • JSONSchemaParserConfig (153-154)
  • OpenAPIParserConfig (157-160)
  • ParserConfig (34-145)
src/datamodel_code_generator/config.py (4)
  • GraphQLParserConfig (327-331)
  • JSONSchemaParserConfig (334-335)
  • OpenAPIParserConfig (338-343)
  • ParserConfig (201-324)
src/datamodel_code_generator/_types/parser_config_dicts.py (2)
src/datamodel_code_generator/model/type_alias.py (1)
  • TypeAlias (37-42)
src/datamodel_code_generator/enums.py (1)
  • OpenAPIScope (70-78)
⏰ 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). (9)
  • GitHub Check: 3.14 on macOS
  • GitHub Check: 3.10 on macOS
  • GitHub Check: 3.13 on Windows
  • GitHub Check: 3.10 on Windows
  • GitHub Check: 3.14 on Windows
  • GitHub Check: 3.12 on Windows
  • GitHub Check: 3.11 on Windows
  • GitHub Check: benchmarks
  • GitHub Check: Analyze (python)
🔇 Additional comments (8)
src/datamodel_code_generator/_types/parser_config_dicts.py (4)

6-8: LGTM: Import additions are appropriate.

The addition of TypeAlias from typing and use of NotRequired from typing_extensions are correct for the project's Python 3.10+ requirement.


148-151: LGTM: GraphQLParserConfig correctly extends ParserConfig.

The inheritance structure is correct, and the two GraphQL-specific fields (data_model_scalar_type, data_model_union_type) appropriately extend the base configuration.


153-161: LGTM: Inheritance chain correctly preserved.

The inheritance structure ParserConfigJSONSchemaParserConfigOpenAPIParserConfig accurately reflects the semantic relationship where OpenAPI extends JSON Schema. The three OpenAPI-specific fields are appropriate additions.


163-163: The Model type alias is not exported in the public API and is not used anywhere in the codebase. The current design exports individual parser config types (ParserConfigDict, GraphQLParserConfigDict, JSONSchemaParserConfigDict, OpenAPIParserConfigDict) rather than a union alias, which appears to be an intentional pattern. No action needed.

tox.ini (1)

119-119: LGTM: Command consolidation aligns with profile consolidation.

The update correctly consolidates four separate datamodel-codegen profile invocations into a single parser-config-dicts profile call, matching the consolidated profile definition in pyproject.toml.

.pre-commit-config.yaml (1)

42-42: LGTM: Pre-commit hook updated consistently.

The consolidation of the datamodel-codegen invocations in the pre-commit hook correctly mirrors the changes in tox.ini and aligns with the unified parser-config-dicts profile.

src/datamodel_code_generator/_types/__init__.py (1)

7-21: LGTM: Public API maintains backward compatibility.

The import aliases correctly map the consolidated config types to their public *Dict names, preserving the existing API surface. The __all__ export list properly includes all four config dict types.

Note: The Model TypeAlias from parser_config_dicts.py is not exported, which should be verified as intentional (see related comment on parser_config_dicts.py).

pyproject.toml (1)

277-285: LGTM: Profile consolidation correctly configured.

The consolidation of four separate parser config profiles into a single parser-config-dicts profile is well-executed:

  • The input-model list appropriately specifies all four config classes
  • The single output file path matches the new consolidated module
  • This configuration correctly drives the TypedDict generation for all parser configs in one file

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

📚 Docs Preview: https://pr-2883.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 Dec 31, 2025

CodSpeed Performance Report

Merging #2883 will not alter performance

Comparing refactor/consolidate-parser-config-profiles (319ee8a) with main (20ad1a1)

⚠️ 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 untouched
⏩ 98 skipped1

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 Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.37%. Comparing base (294acb6) to head (319ee8a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2883   +/-   ##
=======================================
  Coverage   99.37%   99.37%           
=======================================
  Files          92       92           
  Lines       16046    16046           
  Branches     1893     1893           
=======================================
  Hits        15945    15945           
  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 3f06fa4 into main Dec 31, 2025
39 checks passed
@koxudaxi koxudaxi deleted the refactor/consolidate-parser-config-profiles branch December 31, 2025 20:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 1, 2026

🎉 Released in 0.51.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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants