Skip to content

Add public API signature baselines#2832

Merged
koxudaxi merged 5 commits intomainfrom
api-baseline-checks
Dec 28, 2025
Merged

Add public API signature baselines#2832
koxudaxi merged 5 commits intomainfrom
api-baseline-checks

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Dec 28, 2025

Related PRs: #2830

Summary by CodeRabbit

  • Tests
    • Added API signature baseline validation tests to ensure consistency and compatibility of the public interface across core entry points and their parameters.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 28, 2025

Warning

Rate limit exceeded

@koxudaxi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3b0ae99 and 4ce0236.

📒 Files selected for processing (1)
  • tests/main/test_public_api_signature_baseline.py
📝 Walkthrough

Walkthrough

Introduces a new test module that defines baseline public API signatures for the generate function and Parser class constructor, including helper utilities to extract and compare keyword-only parameters. Adds tests to verify the actual signatures remain consistent with these baselines, ensuring public API stability without modifying runtime behavior.

Changes

Cohort / File(s) Summary
Test Module & Baselines
tests/main/test_public_api_signature_baseline.py
Adds new test file with two baseline function/class signatures (_baseline_generate with ~90 keyword-only parameters and _BaselineParser with ~95 keyword-only parameters), helper functions (_kwonly_params, _kwonly_by_name) to extract keyword-only parameters from signatures, and two assertion tests (test_generate_signature_matches_baseline, test_parser_signature_matches_baseline) to verify actual public API signatures preserve keyword-only parameter names and type annotations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Baselines laid like careful tracks,
Parameters in perfect stacks,
Tests stand guard with gentle care,
API promises, crystal-clear—
Signatures safe, forevermore!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add public API signature baselines' directly and clearly describes the main change—adding new baseline definitions for public API signatures in a test module.

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 28, 2025

📚 Docs Preview: https://pr-2832.datamodel-code-generator.pages.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 28, 2025

CodSpeed Performance Report

Merging #2832 will not alter performance

Comparing api-baseline-checks (4ce0236) with main (5ca9b4f)

⚠️ 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.

Summary

✅ 11 untouched
⏩ 98 skipped1

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.52%. Comparing base (5ca9b4f) to head (4ce0236).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2832   +/-   ##
=======================================
  Coverage   99.52%   99.52%           
=======================================
  Files          89       90    +1     
  Lines       13964    13993   +29     
  Branches     1665     1667    +2     
=======================================
+ Hits        13897    13926   +29     
  Misses         36       36           
  Partials       31       31           
Flag Coverage Δ
unittests 99.52% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/main/test_public_api_signature_baseline.py (1)

299-314: Consider checking default values for more comprehensive API stability.

The tests currently verify parameter names and type annotations, which catches most breaking changes. However, they don't verify default values, which could also affect API stability if callers depend on specific default behavior.

For example, if a parameter's default changes from True to False, the tests would pass but existing code relying on the default might break.

🔎 Optional enhancement to check defaults
 def test_generate_signature_matches_baseline() -> None:
     """Ensure generate keeps the origin/main kw-only args and annotations."""
     expected = inspect.signature(_baseline_generate)
     actual = inspect.signature(generate)
     assert _kwonly_by_name(actual).keys() == _kwonly_by_name(expected).keys()
     for name, param in _kwonly_by_name(expected).items():
         assert _kwonly_by_name(actual)[name].annotation == param.annotation
+        # Optionally also check default values to catch changes in default behavior
+        assert _kwonly_by_name(actual)[name].default == param.default

Apply similar change to test_parser_signature_matches_baseline.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca9b4f and 3b0ae99.

📒 Files selected for processing (1)
  • tests/main/test_public_api_signature_baseline.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/main/test_public_api_signature_baseline.py (2)
src/datamodel_code_generator/__init__.py (1)
  • generate (450-1018)
src/datamodel_code_generator/parser/base.py (2)
  • Parser (682-3167)
  • title_to_class_name (618-621)
🪛 GitHub Actions: Lint
tests/main/test_public_api_signature_baseline.py

[error] 183-183: ruff-format: code formatting changes were made (extra_template_data parameter indentation). The hook reformatted the file and the CI step exited with code 1.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: py312-isort5 on Ubuntu
  • GitHub Check: 3.10 on Ubuntu
  • GitHub Check: 3.13 on Windows
  • GitHub Check: 3.10 on Windows
  • GitHub Check: py312-black24 on Ubuntu
  • GitHub Check: 3.14 on Ubuntu
  • GitHub Check: 3.12 on Windows
  • GitHub Check: 3.11 on Windows
  • GitHub Check: 3.12 on Ubuntu
  • GitHub Check: 3.14 on Windows
  • GitHub Check: benchmarks
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
tests/main/test_public_api_signature_baseline.py (2)

1-43: LGTM!

The import structure is well-organized, with appropriate use of TYPE_CHECKING to minimize runtime overhead while providing full type annotations for the baseline signatures.


291-296: LGTM!

The helper functions correctly extract keyword-only parameters using inspect.Parameter.KEYWORD_ONLY, providing clean utilities for signature comparison.

Comment thread tests/main/test_public_api_signature_baseline.py Outdated
@koxudaxi koxudaxi merged commit fdfd342 into main Dec 28, 2025
34 checks passed
@koxudaxi koxudaxi deleted the api-baseline-checks branch December 28, 2025 07:42
@github-actions
Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR only adds a new test file (test_public_api_signature_baseline.py) that creates baseline signatures for the generate function and Parser.__init__ method, then tests that the actual implementations match these baselines. It is purely test infrastructure that will help detect future breaking changes. The PR does not modify any production code, CLI options, default behaviors, templates, or error handling - it only adds tests to ensure API signature stability going forward.


This analysis was performed by Claude Code Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 1, 2026

🎉 Released in 0.51.0

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