Skip to content

Annotate ty ignores#3587

Merged
koxudaxi merged 2 commits into
mainfrom
agent/type-ignore-comments
Jul 7, 2026
Merged

Annotate ty ignores#3587
koxudaxi merged 2 commits into
mainfrom
agent/type-ignore-comments

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Updated type-checking annotations throughout the codebase to improve code quality and precision of static analysis diagnostics.

Note: This release contains no user-visible changes or new features. All modifications are internal code maintenance improvements.

@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: d006b20a-2aa1-48b0-a39b-dd1f313a9c03

📥 Commits

Reviewing files that changed from the base of the PR and between 171783e and d9c262c.

📒 Files selected for processing (13)
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/dynamic.py
  • src/datamodel_code_generator/input_model.py
  • src/datamodel_code_generator/model/pydantic_v2/__init__.py
  • src/datamodel_code_generator/model/pydantic_v2/types.py
  • src/datamodel_code_generator/parser/asyncapi.py
  • src/datamodel_code_generator/parser/base.py
  • src/datamodel_code_generator/parser/graphql.py
  • src/datamodel_code_generator/parser/openapi.py
  • src/datamodel_code_generator/reference.py
  • src/datamodel_code_generator/types.py
  • src/datamodel_code_generator/util.py
  • tests/main/test_main_general.py

📝 Walkthrough

Walkthrough

This PR replaces generic # type: ignore and # ty: ignore type-checker suppression comments with more specific error codes (e.g., invalid-argument-type, unresolved-attribute, invalid-assignment, redundant-cast) across the codebase. It also adds an explicit cast("Any", generation_config) when calling generate(...). No runtime logic changes.

Changes

Typing suppression refinement

Layer / File(s) Summary
CLI generate call cast
src/datamodel_code_generator/__main__.py, tests/main/test_main_general.py
run_generate_from_config now passes cast("Any", generation_config) to generate(...); matching snapshot test updated.
Dynamic model and pydantic_v2 suppressions
src/datamodel_code_generator/dynamic.py, src/datamodel_code_generator/input_model.py, src/datamodel_code_generator/model/pydantic_v2/__init__.py, src/datamodel_code_generator/model/pydantic_v2/types.py
Type-ignore comments on cache assignment, model rebuild/schema loading, $defs checks, ConfigDict.dict, and strict-type assignment narrowed to specific error codes.
Parser suppressions
src/datamodel_code_generator/parser/asyncapi.py, src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/parser/graphql.py, src/datamodel_code_generator/parser/openapi.py
Ignore comments on init calls, config validation, enum aliasing, resolver naming, GraphQL resolver kind/base classes, and OpenAPI field/response assignments narrowed to specific error codes.
Reference, types, and util suppressions
src/datamodel_code_generator/reference.py, src/datamodel_code_generator/types.py, src/datamodel_code_generator/util.py
Ignore comments on context variable calls, cast, find_source, TOML lazy import, and CustomSafeLoader narrowed to specific error codes.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating type-ignore annotations to ty-specific suppressions.
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-ignore-comments

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-3587.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-ignore-comments (d9c262c) with main (171783e)

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.

@koxudaxi koxudaxi force-pushed the agent/type-safety-phase-1 branch from d8e02ba to 0f7da9c Compare July 7, 2026 14:02
@koxudaxi koxudaxi force-pushed the agent/type-ignore-comments branch from 3b434fb to 5582e30 Compare July 7, 2026 14:04
Base automatically changed from agent/type-safety-phase-1 to main July 7, 2026 14:15
@koxudaxi koxudaxi enabled auto-merge (squash) July 7, 2026 14:41
@koxudaxi koxudaxi force-pushed the agent/type-ignore-comments branch from 7a00a86 to d9c262c Compare July 7, 2026 15:02
@koxudaxi koxudaxi merged commit ec07ba2 into main Jul 7, 2026
103 of 105 checks passed
@koxudaxi koxudaxi deleted the agent/type-ignore-comments branch July 7, 2026 17:21
@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 (171783e) to head (d9c262c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3587   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          164       164           
  Lines        35243     35243           
  Branches      4063      4063           
=========================================
  Hits         35243     35243           
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.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: PR #3587 ("Annotate ty ignores") only modifies type-checker suppression comments — refining # ty: ignore to include specific diagnostic codes (e.g. [unresolved-attribute], [invalid-assignment]) and migrating # type: ignore[...] comments to # ty: ignore[...]. The single non-comment code change wraps config=generation_config in cast("Any", ...), which is a runtime no-op (typing.cast returns its argument unchanged), and the corresponding test snapshot was updated to match. No CLI options, Python API signatures, default behaviors, generated code output, Jinja2 templates, error handling, or supported Python versions are changed. There are no breaking changes.


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