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
Import the type expression reader of the model renames where they run, so a run without models does not load it - #6043
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.
The localized import change presents no identified merge-blocking issue and is mergeable subject to normal checks.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and accurately describes the main change: it moves the type expression reader import to the code path where model renames run, preventing unnecessary loading when no models exist.
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
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.
Reviewing files that changed from the base of the PR and between d057e152f6e0ff10d1348d62ccb2f5a5252a7411 and 24192e40345fd9b65e9eed9a6de9ea33ae4da371.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
⚠️52 benchmarks with a significant change ran on different hardware
Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.
Hyphenated directory (#6039). A directory is read as importable by its name once its `-` is `_`, as the output writes it
(`written_name`): `café-models` is written to `café_models/` and imported by that name, as the files of 0.88.0 were
written, where the check came before the `-` was replaced and the directory was sanitized as a file's name is
(`caf__models`), so it moved and two directories of the same length (`café-models`, `cafè-models`) shared one package. The
import of such a directory was a syntax error up to 0.88.0 (`from .café-models import a`), so only output that failed to
import changes.
Names an additional import binds (#6041). A type of a module that writes a dotted name writes the first name of it where
the module's names are read (`ipaddress.IPv4Address` binds `ipaddress`), not the last one. The check of the imports every
module writes that a model of the module shadows reads that first name (`iter_python_type_expr_head_names`), so a model
named like the last name of a qualified runtime symbol (`x-python-import` `symbols`) keeps its name, as in 0.88.0. The
name a model or an import takes anew where a shared import binds the name it had skips the names the shared imports bind
(`shared_import_bindings`), so `IPv4Address1` is not given to a model where `mymod.IPv4Address1` is imported by every
module, nor `Status_1` or `list_1` to the import a package names anew.
Enum member defaults (#6040). `set_default_enum_member` writes a member by the expression its type names the enum by when
it runs, so a default kept naming the import that the passes of the imports named anew afterwards (`Status` for
`Status as Status_1`, `list.Pop` for `list_1.Pop`) and the generated module failed to import. The two passes that name an
import anew write the new expression into the members of the defaults that use it (`name_enum_member`, a store mutation
with its row in the fact table).
Item counts (#6037). The item counts that `contains` and boolean `items` imply belong to a field whose schema admits an
array (it declares no type, or an array is one of them) as well as whose type can hold one: a string typed
`datetime.date` and an object with array values (`{"type": "object", "additionalProperties": {"type": "array"}}`) took
`min_length` from them, which raised `Unable to apply constraint` for a date and rejected the maps with fewer keys.
Reasoning: I read the whole diff. The main behaviour change is in jsonschema.py: a new admits_array check in _assemble_field_constraints stops item counts implied by contains or minContains from becoming length constraints on properties whose schema declares no array type, such as an object map with array values or a string retyped via x-python-type. The behaviour diff gate marks the msgspec cell for the new array_counts_beside_retyped input as accepted because Meta min_length was dropped from the map field. The allowlist update and the new expected output show the same change for Pydantic, so default generated code changes. Separately, _names_written_as_text now checks the head name of a dotted type instead of its last name. Under --additional-imports, a model named like an imported name is therefore no longer renamed when the module only writes that name qualified, which changes the class name for those users. I treated the other changes as fixes to broken output and not as breaking changes. These are: enum member defaults now follow renamed import aliases; import and model renames now skip names already bound by additional imports; hyphenated non-ASCII directory names are now sanitized the same way their files are written. The behaviour gate marks the related cells as crash-fix or both-fail, or they fix outputs that were broken before. The remaining changes are internal helper additions, docs, the fact table and tests. No CLI options, public API, templates or Python version support were removed or changed.
Content for Release Notes
Code Generation Changes
Item counts no longer applied to properties whose schema declares no array type - A property whose schema declares a type without array (for example type: object with array-valued additionalProperties, or type: string retyped with x-python-type: datetime.date) no longer gets the minItems/maxItems that contains, minContains or items: false imply as a length constraint. A map field that used to be generated as Annotated[dict[str, list[str]], Meta(min_length=2)] (msgspec) or with Field(None, min_length=2) (Pydantic) is now a plain dict[str, list[str]], so generated models now accept maps with fewer entries, which the schema also accepts. A string retyped as a date no longer gets a length constraint that failed when the model was imported (Import the type expression reader of the model renames where they run, so a run without models does not load it #6043)
Models named like an additional import keep their name when types only write the import qualified - With --additional-imports, a model whose name matches an imported name is no longer renamed when the module's types write that name only through its module path (for example a type written as ipaddress.IPv4Address alongside --additional-imports ipaddress.IPv4Address and a model titled IPv4Address). The model cannot shadow the import in that case, so it now keeps its schema name instead of the suffixed name it got before. Code that referenced the previously renamed class must switch to the original name (Import the type expression reader of the model renames where they run, so a run without models does not load it #6043)
This analysis was produced by the release draft workflow
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