Skip to content

Fix ty diagnostics#3585

Merged
koxudaxi merged 1 commit into
mainfrom
agent/type-safety-phase-1
Jul 7, 2026
Merged

Fix ty diagnostics#3585
koxudaxi merged 1 commit into
mainfrom
agent/type-safety-phase-1

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved generation reliability for JSON Schema and OpenAPI inputs with more precise schema validation behavior.
    • Deprecated-item handling now emits warnings rather than silently ignoring them, helping surface issues earlier.
  • Tests

    • Updated test snapshots/expectations to reflect the latest configuration passing behavior during generation.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3bbc1780-1777-48bf-807c-b04054874022

📥 Commits

Reviewing files that changed from the base of the PR and between d8e02ba and 0f7da9c.

📒 Files selected for processing (5)
  • pyproject.toml
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • src/datamodel_code_generator/parser/openapi.py
  • tests/main/test_main_general.py
✅ Files skipped from review due to trivial changes (2)
  • tests/main/test_main_general.py
  • src/datamodel_code_generator/parser/openapi.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/datamodel_code_generator/main.py
  • pyproject.toml

📝 Walkthrough

Walkthrough

This PR updates ty deprecated-rule handling, tightens type annotations in the generate entrypoint and parser code, removes now-unneeded ty: ignore comments, and adjusts one snapshot test to match the new generate call shape.

Changes

Type-checking cleanup for ty tool warnings

Layer / File(s) Summary
Enable ty deprecated warning
pyproject.toml
Changes [tool.ty].rules.deprecated from "ignore" to "warn".
Tighten generate config typing
src/datamodel_code_generator/__main__.py, tests/main/test_main_general.py
_get_config_class returns type[Config]; generate() passes generation_config directly; the pinned snapshot is updated to match.
Jsonschema predicate narrowing
src/datamodel_code_generator/parser/jsonschema.py
Imports TypeIs and changes _is_required_only_schema to return TypeIs[JsonSchemaObject].
OpenAPIParser config typing
src/datamodel_code_generator/parser/openapi.py
Explicitly types OpenAPIParser.config as OpenAPIParserConfig and removes # ty: ignore comments from config-derived assignments.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the change, but it is too generic to convey the specific type-safety and annotation updates in the patch. Use a more specific title like "Tighten typing annotations to fix ty diagnostics" or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/type-safety-phase-1

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.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 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.

✅ 13 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing agent/type-safety-phase-1 (0f7da9c) with main (625780c)

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 Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3585   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          163       164    +1     
  Lines        35196     35243   +47     
  Branches      4063      4063           
=========================================
+ Hits         35196     35243   +47     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Harness.
📢 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 force-pushed the agent/type-safety-phase-1 branch from d8e02ba to 0f7da9c Compare July 7, 2026 14:02
@koxudaxi koxudaxi merged commit 171783e into main Jul 7, 2026
63 checks passed
@koxudaxi koxudaxi deleted the agent/type-safety-phase-1 branch July 7, 2026 14:15
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: PR #3585 only contains internal type-checking improvements with no runtime effect: (1) _get_config_class return annotation changed from type to type[Config]; (2) removed a cast("Any", ...) wrapper around generation_config; (3) _is_required_only_schema return type refined from bool to TypeIs[JsonSchemaObject] (a typing-only construct); (4) removed # ty: ignore comments in openapi.py and added a config: OpenAPIParserConfig class annotation; (5) flipped the ty type-checker rule rules.deprecated from ignore to warn in pyproject.toml (affects the linter, not users). The test change only updates a snapshot to match the removed cast. No generated code output, CLI/API options, default behavior, Python version support, or error handling changed.


This analysis was performed by Claude Code Action

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.68.1

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