Skip to content

Test typing imports and union tags through the public surface - #7307

Merged
Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
reexports-and-cycle
Nov 21, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
reexports-and-cycle

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Removed access to several internal compatibility helpers. This does not change the application’s user-facing behavior.
  • Tests
    • Updated checks for type-import handling and discriminator values, including empty-string values.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes remove private helper imports from model.base and parser.jsonschema. Related tests now check field imports and include an empty-string discriminator const case. The import allowlists no longer include exceptions for these helpers.

Changes: Private helper export cleanup

Layer / File(s) Summary
Remove helper imports and update tests
src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/parser/jsonschema.py, tests/model/test_base.py, tests/parser/test_jsonschema.py, tests/assert_helper_allowlists.py
Removed imports that exposed private helpers through the two modules. Tests now check field imports and include an empty-string discriminator const case. Removed the related legacy import exceptions.

Estimated code review effort: 2 (Simple) | ~7 minutes

Change: Other

Merge Risk: Minimal · up to ee08c

This change removes private helper re-exports and tests the typing imports and union tags through the public interface. No user-facing behavior change or merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says the PR tests typing imports and union tags through the public surface. The changeset matches this. It removes private re-exports of _get_json_value_type, _get_union_variant_name, an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says the PR tests typing imports and union tags through the public surface. The changeset matches this. It removes private re-exports of _get_json_value_type, _get_union_variant_name, and _annotation_typing_import_names from the public-facing modules. It also replaces tests that imported these private helpers with tests that exercise DataModelFieldBase.imports and the discriminator-literal path. The title names the main change, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a069377 and ee08c6e.

Files selected for processing: 5

  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • tests/assert_helper_allowlists.py
  • tests/model/test_base.py
  • tests/parser/test_jsonschema.py
Files with no reviewable changes: 3

  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • tests/assert_helper_allowlists.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T15:23:30.946808Z ee08c6e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

✅ 53 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing reexports-and-cycle (ee08c6e) with main (a069377)

Open in CodSpeed

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

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit b5e753c into main Nov 21, 2026
118 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the reexports-and-cycle branch November 21, 2026 15:42
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR only removes three private, underscore-prefixed re-exports: _annotation_typing_import_names from model.base, and _get_json_value_type and _get_union_variant_name from parser.jsonschema. The helpers themselves still exist in their private modules, so this is just internal cleanup. The PR also updates tests and the test allowlist to match. No public Python API, CLI option, template, default value, error handling or Python version support changes. The behaviour diff gate lists only both-fail cells and no accepted or violation cells, so default generated output is unchanged.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

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

1 participant