Repository navigation
Walk to an existing ancestor and place the staging directory in one place each - #5723
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared ancestor lookup and callers src/datamodel_code_generator/_paths.py, src/datamodel_code_generator/_publication.py, src/datamodel_code_generator/_api_generation.py, src/datamodel_code_generator/remote_lock.py, src/datamodel_code_generator/watch_dependencies.py |
Adds existing_ancestor with configurable matching, root handling, and missing-path collection. Publication, staging, remote-lock, and watch-dependency code now use it. Staging selection accepts optional cwd and around paths. |
Decision-home signatures and records scripts/check_decision_homes.py, scripts/decision_homes.toml, tests/data/decision_homes/src/other.py, tests/test_decision_homes.py, docs/architecture.md |
Adds an ancestor-walk signature to the checker and a fixture for that signature. Adds decision records and documents the ancestor lookup modes and two legacy behaviors. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Possibly related issues
- datamodel-code-generator/datamodel-code-generator issue 5722: The pull request updates the ancestor walks associated with staging, publication anchors, and parent creation.
- datamodel-code-generator/datamodel-code-generator issue 5618: The pull request changes staging-parent selection and documents the case where the nearest existing ancestor is a regular file.
Possibly related PRs
- datamodel-code-generator/datamodel-code-generator#5422: This pull request adds decision-home records and a checker signature that use the earlier PR’s legacy-row consistency contract.
- datamodel-code-generator/datamodel-code-generator#5506: This pull request updates
staging_directory_for, introduced in that PR, and changes_api_generation._stagingto delegate to it.
Merge Risk: 
Minimal · up to 576f7
-
No merge-blocking issue is identified. The ancestor-lookup consolidation and decision-home updates appear mergeable subject to normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 85.71% 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 7 functions across 8 files. (2 skipped: 2 unsupported.)
-
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.
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will degrade performance by 18.9%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is an internal refactor and adds no breaking changes. It moves several hand-written loops that climb a path's parents (in _publication.py publication_anchor, staging_directory_for and _create_target_parent, in _api_generation.py _staging, in remote_lock.py _nearest_existing_directory and in watch_dependencies.py _nearest_existing_directory) into one new private helper, _paths.existing_ancestor. The helper has named rows that keep each caller's old behaviour. The publication walks still keep going past a root that does not exist (legacy-unbounded-ancestor-walk). Private staging still accepts any existing path, a regular file included (legacy-staging-parent-may-be-a-file). The remote lock still raises RemoteLockError with the same message at a missing root, and the watcher still returns the root. staging_directory_for is in a private module and only gains optional keyword-only cwd and around parameters. With neither given, it computes the same staging parent as before, and _api_generation._staging now calls it with the same logic it had inline. Everything else is tooling, docs and tests: a new ancestor-walk signature kind in scripts/check_decision_homes.py, new rows in decision_homes.toml, two new architecture doc rows, and decision-home test fixtures. No CLI option, public Python API, template, Python version support or error message changes. The behaviour diff gate does list accepted cells, but all of them are allOf intersection changes that come from earlier work since the last release, which the gate notes credit to 5401. This PR does not touch any parser or model code, so those cells are not caused by this diff. This analysis was produced by the release draft workflow |
|
🎉 Released in 0.88.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit