You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hoist the local imports of modules that are already loaded - #7265
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The pull request moves imports from function-local scopes to module scope across source loading, parsing, model handling, and generation modules. The supplied summaries report no changes to runtime behavior or public declarations.
Imports used by source decoding, recommendation setup, input-model loading, and document utilities move to module scope. Existing function logic remains unchanged.
Imports used by parser passes, schema validation, and format-specific parsing move to module scope. The summaries report unchanged validation, normalization, and conversion behavior.
Model and target handling src/datamodel_code_generator/_target_binding.py, src/datamodel_code_generator/_target_templates.py, src/datamodel_code_generator/model/__init__.py, src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/model/enum.py, src/datamodel_code_generator/model/pydantic_v2/base_model.py, src/datamodel_code_generator/python_literal.py
Imports used by model construction, target binding, template handling, and literal rendering move to module scope. Existing call-site behavior remains unchanged.
Imports used by generation, API planning, configuration, formatting, CLI, client rendering, debugging, and watch modules move to module scope. The summaries report no public declaration or runtime behavior changes.
This is an import-organization refactor with no intended behavior change. No concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Hoist the local imports of modules that are already loaded" matches the main change. The raw summary shows many function-local imports moved to module scope across parser, model, client, an…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Hoist the local imports of modules that are already loaded" matches the main change. The raw summary shows many function-local imports moved to module scope across parser, model, client, and root modules. The PR objectives describe the same goal. The title is specific and describes the primary change. The title does not mention the retained test-patched and public-API-recorded imports, but that detail is not required.
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
Reasoning: The PR is a mechanical refactor that moves function-local imports, previously marked noqa PLC0415, and some TYPE_CHECKING-only imports up to module-level imports across 37 source files, and swaps from-importlib import_module for importlib.import_module calls. No public options, parameters, classes, enum values or functions are removed or renamed, since every removed line is an import that reappears at module level. Generated output, templates, defaults, error types and messages, and supported Python versions are unchanged, and the behaviour diff gate reports only both-fail cells with no accepted or violation cells, so default output behaviour does not change.
This analysis was produced by the release draft workflow
This PR is now available in the latest release. See the release notes for details.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit