Skip to content

Fix test data backspace escape#2718

Merged
koxudaxi merged 1 commit intomainfrom
fix-x08-test-data
Dec 21, 2025
Merged

Fix test data backspace escape#2718
koxudaxi merged 1 commit intomainfrom
fix-x08-test-data

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Dec 21, 2025

Summary by CodeRabbit

  • Tests

    • Updated pattern validation and enum test cases with standardized character representation.
  • Chores

    • Standardized character representation in JSON Schema and OpenAPI schema definitions.

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 21, 2025

Walkthrough

The pull request systematically replaces backspace character escape sequences from \b to \x08 (hexadecimal representation) across test data files and their expected Python output files for JSON Schema and OpenAPI specifications. All replacements maintain semantic equivalence.

Changes

Cohort / File(s) Summary
JSONSchema Expected Pattern Files
tests/data/expected/main/jsonschema/pattern.py
Updated regex pattern to replace backspace escape \b with hex escape \x08 in negated character class
JSONSchema Expected Special Enum Files
tests/data/expected/main/jsonschema/special_enum.py, special_enum_empty_enum_field_name.py, special_enum_special_field_name_prefix.py, special_enum_special_field_name_prefix_keep_private.py
Removed enum members with \b value, added corresponding members with \x08 hex representation; shifted enum member ordering
OpenAPI Expected Pattern Files
tests/data/expected/main/openapi/pattern/general.py, msgspec_pattern.py, pydantic_v2.py
Updated regex pattern in comment field constraints to use \x08 instead of \b in negated character class
JSONSchema Source Files
tests/data/jsonschema/pattern.json, special_enum.json
Updated enum/pattern values to replace \b with \x08 in JSON schema definitions
OpenAPI Source Files
tests/data/openapi/pattern.yaml
Updated regex pattern in comment property to replace \b with \x08 in YAML spec

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Homogeneous changes across multiple files—all following identical replacement pattern (\b\x08)
  • Test data and expected output files only; no production logic affected
  • Consider verifying that all affected files received consistent updates (no missed occurrences)

Poem

🐰 A backspace by another name still reads the same,
From \b to \x08, hexadecimal's the game,
Across our test files, consistent and bright,
The escape sequences dance in the light,
Our schemas now uniform—what a delight!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating test data files to fix backspace escape representations from \b to \x08 across multiple test files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-x08-test-data

📜 Recent 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 9f7e40d and f85e024.

📒 Files selected for processing (11)
  • tests/data/expected/main/jsonschema/pattern.py (1 hunks)
  • tests/data/expected/main/jsonschema/special_enum.py (1 hunks)
  • tests/data/expected/main/jsonschema/special_enum_empty_enum_field_name.py (1 hunks)
  • tests/data/expected/main/jsonschema/special_enum_special_field_name_prefix.py (1 hunks)
  • tests/data/expected/main/jsonschema/special_enum_special_field_name_prefix_keep_private.py (1 hunks)
  • tests/data/expected/main/openapi/pattern/general.py (1 hunks)
  • tests/data/expected/main/openapi/pattern/msgspec_pattern.py (1 hunks)
  • tests/data/expected/main/openapi/pattern/pydantic_v2.py (1 hunks)
  • tests/data/jsonschema/pattern.json (1 hunks)
  • tests/data/jsonschema/special_enum.json (1 hunks)
  • tests/data/openapi/pattern.yaml (1 hunks)
⏰ 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). (8)
  • GitHub Check: benchmarks
  • GitHub Check: 3.14 on Windows
  • GitHub Check: 3.13 on Windows
  • GitHub Check: 3.12 on macOS
  • GitHub Check: 3.11 on Windows
  • GitHub Check: 3.10 on Windows
  • GitHub Check: 3.10 on macOS
  • GitHub Check: 3.12 on Windows
🔇 Additional comments (11)
tests/data/openapi/pattern.yaml (1)

25-25: LGTM! More explicit backspace representation.

The change from \b to \x08 in the character class is semantically equivalent (both match backspace character 0x08), but \x08 is more explicit and avoids confusion with word boundary assertions.

tests/data/jsonschema/pattern.json (1)

20-20: LGTM! Semantically equivalent change.

Replacing \\b with \\x08 maintains the same regex semantics (both exclude backspace character 0x08 from the character class) while being more explicit.

tests/data/expected/main/jsonschema/pattern.py (1)

20-20: LGTM! Expected output correctly reflects input schema change.

The generated regex pattern uses \x08 instead of \b, maintaining semantic equivalence while being more explicit about the backspace character.

tests/data/expected/main/openapi/pattern/msgspec_pattern.py (1)

25-25: LGTM! Consistent with other pattern updates.

The msgspec output correctly reflects the more explicit \x08 backspace representation in the pattern.

tests/data/jsonschema/special_enum.json (1)

11-11: Verify the semantic change from backspace character to literal string.

The change from "\b" to "\\x08" in JSON represents a semantic shift:

  • Before: backspace character (single byte 0x08)
  • After: literal 4-character string "\x08"

This impacts how the code generator interprets and names the enum member (now field_x08 instead of field__3). Confirm this change is intentional—likely to test handling of literal escape sequences rather than unprintable characters.

tests/data/expected/main/openapi/pattern/general.py (1)

21-21: LGTM! Consistent pattern update.

The expected output correctly uses the more explicit \x08 hex escape for backspace in the regex pattern.

tests/data/expected/main/jsonschema/special_enum.py (1)

19-20: LGTM! Expected output reflects input changes.

The enum members correctly reflect the input change:

  • New field_x08 for the literal string "\x08"
  • Backslash value moved to field__3

Consistent with the semantic change noted in special_enum.json (pending verification of intent).

tests/data/expected/main/jsonschema/special_enum_special_field_name_prefix.py (1)

19-20: LGTM! Consistent with other enum updates.

The expected output correctly reflects the input semantic change with the appropriate "special_" prefix for enum members.

tests/data/expected/main/jsonschema/special_enum_empty_enum_field_name.py (1)

19-20: Escape sequence representation is correct and semantically equivalent.

The backspace character is encoded as hex 08, making \b equivalent to \x08. The file correctly uses the Python syntax '\\x08' at line 19 to represent this character, and the field name field_x08 appropriately reflects the hexadecimal notation. This change improves code clarity by using an explicit hex escape instead of the ambiguous \b character.

Verify that the generated models continue to pass all existing tests to confirm this change produces correct runtime behavior.

tests/data/expected/main/openapi/pattern/pydantic_v2.py (1)

22-22: The regex pattern already uses \x08 in both files; no change from \b occurred.

Inside a character class, \b matches the backspace character; outside of a character class, it matches a word boundary. While the semantically identical escape sequence \x08 is recommended for character classes, the actual repository files show that both general.py and pydantic_v2.py already use \x08 in the pattern. The source input file pattern.yaml contains pattern: '[^\x08\f\n\r\t\\a+.?''"|()]+$', and both expected output files contain the identical pattern with \x08.

The only difference between the files is the parameter name: general.py uses regex= (Pydantic v1) while pydantic_v2.py uses pattern= (Pydantic v2). Both patterns are consistent.

Test coverage exists: the test_main_openapi_pattern test parametrizes both pydantic.BaseModel (general.py) and pydantic_v2.BaseModel (pydantic_v2.py), validating that both output files are generated correctly from the same source.

Likely an incorrect or invalid review comment.

tests/data/expected/main/jsonschema/special_enum_special_field_name_prefix_keep_private.py (1)

19-20: The naming in this file is correct and consistent. The _x08 and other field names (__1, __, __2, __3) are all generated by the same naming rules when using an empty special_field_name_prefix. The variation in underscore counts reflects how different source characters sanitize through the regex transformation, not an inconsistency. All names follow the identical transformation logic and are valid Python identifiers.

Likely an incorrect or invalid review comment.


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.34%. Comparing base (3e7b16b) to head (f85e024).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2718   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files          82       82           
  Lines       11611    11656   +45     
  Branches     1405     1410    +5     
=======================================
+ Hits        11535    11580   +45     
  Misses         45       45           
  Partials       31       31           
Flag Coverage Δ
unittests 99.34% <ø> (+<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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 21, 2025

CodSpeed Performance Report

Merging #2718 will not alter performance

Comparing fix-x08-test-data (f85e024) with main (9f7e40d)

Summary

✅ 59 untouched
⏩ 10 skipped1

Footnotes

  1. 10 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.

@koxudaxi koxudaxi merged commit 3aeab90 into main Dec 21, 2025
36 checks passed
@koxudaxi koxudaxi deleted the fix-x08-test-data branch December 21, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant