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
Select python-re for a repetition whose minimum exceeds its maximum, import a model of a module that a shared import names under an alias, give item counts only to fields that can hold an array, and watch a JSON file named like inline JSON - #6037
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.
Generated models can accept arrays that violate the schema's minimum item count. Preserve array-specific validation for referenced roots and untyped properties without constraining non-array values before merging.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title lists four changes: python-re engine selection for reversed counted repetitions, aliasing a model import that collides with a shared import name, limiting item counts to fields that can hold…
Docstring Coverage
Docstring coverage is 86.96% 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. Documentati…
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 lists four changes: python-re engine selection for reversed counted repetitions, aliasing a model import that collides with a shared import name, limiting item counts to fields that can hold arrays, and watching a JSON file whose name resembles inline JSON. Each appears in the summarized changes (regex engine selection in _regex_syntax.py and the pydantic accepted-forms tests, import binding in _import_binding.py and generated shared_import_named_like_module_and_model files, can_hold_array and counts_beside_models in jsonschema.py and _value_keywords.py, and names_file/json_file with watch tests). The title is accurate but long at 239 characters and 44 words, and it joins four unrelated fixes into one sentence. It does not name a single primary change, so it is broad rather than focused. The objectives confirm these four themes, so the title is related to the changeset and not misleading.
Full details: Docstring Coverage
Explanation
Docstring coverage is 86.96% 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 23 functions across 19 files. (8 skipped: 7 unsupported, 1 too large.)
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 7eac448 and d9ebaaf1f155183c269b8003b25870a1806863db.
Files ignored due to path filters: 9
docs/llms-full.txt is excluded by none and included by none
tests/data/expected/main/generation_platform/client/auth-errors.txt is excluded by !tests/data/**/*.txt and included by none
tests/data/expected/main/jsonschema/pydantic_accepted_forms/counted_repetitions_with_a_minimum_above_the_maximum_select_the_python_engine.payloads.txt is excluded by !tests/data/**/*.txt and included by none
tests/data/jsonschema/field_constraint_sites/array_counts_beside_other_types.json is excluded by !tests/data/**/*.json and included by none
tests/data/jsonschema/field_constraint_sites/array_counts_root_reference.json is excluded by !tests/data/**/*.json and included by none
tests/data/jsonschema/rust_unsupported_reversed_repetition.json is excluded by !tests/data/**/*.json and included by none
tests/data/jsonschema/shared_import_named_like_model/api.json is excluded by !tests/data/**/*.json and included by none
tests/data/jsonschema/shared_import_named_like_model/common.json is excluded by !tests/data/**/*.json and included by none
tests/data/payloads/field_constraint_sites/array_counts_beside_other_types.json is excluded by !tests/data/**/*.json and included by none
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 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.
…import a model of a module that a shared import names under an alias, give item counts only to fields that can hold an array, and watch a JSON file named like inline JSON
Fixes for the unresolved review findings of #6013, #6014, #6016, #6032 and #6033.
The scan of regex syntax reads the two counts of a counted repetition and reports one whose minimum exceeds its maximum,
which the Rust engine rejects at import. Python's `re` reads such a repetition as text where whitespace or a verbose
comment is inside (`a{ 3 , 2 }`), so the model selects python-re; without whitespace both engines reject it, as before.
A model imported from its module because a shared import binds the module's name (`from .IPv4Address import
OrderedDict`) rebound `OrderedDict` where another shared import (`--external-ref-mapping common.json=collections`)
binds it too, and the field typed by the mapped type got the model. The import takes an alias then (`OrderedDict_1`):
`ReferenceImportTarget.reserve_name` keeps the resolver of the module from giving it the shared name, in the import it
adds and in the replay of the released names.
`scope_problem` names the shape of scopes that are not an array of strings before it judges tokens, so a scheme that
takes no scope tokens (`apiKey`, `http`) no longer reports "requires valid scope tokens" for `bearer: 42`.
The item counts that boolean `items` and `contains` imply belong to an array. A root model took them for every type
since the root read them as a property does, so `{"type": "string", "contains": true, "minContains": 2}` became
`min_length=2` and rejected the strings the schema accepts, as the property of that schema always did, and a root
that names a model (`{"$ref": "#/$defs/Names", "contains": true, "minContains": 2}`) got a `min_length` that Pydantic
cannot apply to a model, which raised at the first array. A field whose type is no array (a scalar, a mapping, `Any`)
takes none (`can_hold_array`), and neither does a root beside a model, as in 0.88.0; a custom type and a union with an
array keep them. An object property beside a model keeps them as in 0.88.0 (row `legacy-property-counts-beside-models`).
The behaviour diff against 0.88.0 accepts the property change of the new fixture.
The allowlist entries of the property maps of a type list that joins an array match the minProperties and
maxProperties change only (the constraint, default, required and constructor-order lines it makes), not any change of
that field.
A JSON option value that starts like inline JSON names a file where one exists, which the option reads first
(`json_file`, moved from `json_config` to `_config_fields`). `--watch` watches that file (`names_file`) in the watch
graph of a run and in the recovery of a failed plan; the resolver of the planned job is unchanged.
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.
…, so a run without models does not load it (#6043)
* Import the type expression reader of the model renames where they run, so a run without models does not load it
* Fix the unresolved review findings of #6037, #6039, #6040 and #6041
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.
* Provide the module the additional imports of the renamed-import test name, so the output imports on Python 3.10
Reasoning: The full diff was read. The behaviour diff gate marks the array_counts_beside_other_types cells as accepted for Pydantic BaseModel, Pydantic dataclass and msgspec under default options. The new can_hold_array check in the field constraint assembly drops the implied item counts from string and mapping properties, so default generated code changes: MinLen or Meta min_length is removed, and the pydantic dataclass default and constructor order change. This is reported as a code generation change. The other changes are not breaking. Reversed counted repetitions selecting the python-re engine fix models that previously failed at import. The import alias for a model whose name a shared import also binds fixes an edge-case collision. Watch mode now also tracks JSON option files whose names look like inline JSON. The private helpers _json_file and _path_is_file were moved into _config_fields as json_file. The client security scope error message was reworded, but the input still fails the same way. The other accepted cells in the gate come from earlier changes whose allowlist patterns were only tightened here.
Content for Release Notes
Code Generation Changes
Item counts implied by contains or boolean items no longer apply to fields that cannot hold an array - A property whose type is not an array, such as a string or a mapping, that sits beside contains/minContains or items: false used to receive the implied minItems/maxItems as a length constraint (for example Annotated[str | None, MinLen(min_length=2)] for Pydantic or Annotated[str, Meta(min_length=2)] for msgspec), which rejected values the schema accepts. Such fields are now generated without that length constraint (for example tag: str | None = None). For pydantic_v2.dataclass output the field no longer carries a Field(...) default with the constraint, which can also change the field order of the generated dataclass constructor and affect positional construction (Select python-re for a repetition whose minimum exceeds its maximum, import a model of a module that a shared import names under an alias, give item counts only to fields that can hold an array, and watch a JSON file named like inline JSON #6037)
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