Fix stringcase dependency with setuptools 78.0.0#565
Conversation
WalkthroughReplaces the external Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
📚 Docs Preview: https://pr-565.fastapi-code-generator.pages.dev |
Merging this PR will not alter performance
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_parser.py (1)
28-33: Consider broadening camel/pascal compatibility cases.Line 28 currently validates one representative value. A small parametrized matrix would make future behavior drift less likely.
Suggested test extension
+@pytest.mark.parametrize( + ("value", "camel_expected", "pascal_expected"), + [ + ("sample_name", "sampleName", "SampleName"), + ("sampleName", "sampleName", "SampleName"), + ("SampleName", "sampleName", "SampleName"), + ("", "", ""), + ], +) +def test_useful_str_case_helpers_cover_multiple_input_shapes( + value: str, camel_expected: str, pascal_expected: str +) -> None: + useful = UsefulStr(value) + assert useful.camelcase == camel_expected + assert useful.pascalcase == pascal_expected🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_parser.py` around lines 28 - 33, The test test_useful_str_case_helpers_match_legacy_stringcase_behavior currently checks only one input; expand it into a parametrized test that iterates multiple input strings and their expected snakecase, camelcase, and pascalcase outputs to catch regressions. Use the UsefulStr constructor in each case and assert UsefulStr(...).snakecase, .camelcase, and .pascalcase against expected values for a small matrix (e.g., inputs with hyphens, spaces, acronyms, leading/trailing underscores) so the behavior of UsefulStr and its properties is validated across variants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/test_parser.py`:
- Around line 28-33: The test
test_useful_str_case_helpers_match_legacy_stringcase_behavior currently checks
only one input; expand it into a parametrized test that iterates multiple input
strings and their expected snakecase, camelcase, and pascalcase outputs to catch
regressions. Use the UsefulStr constructor in each case and assert
UsefulStr(...).snakecase, .camelcase, and .pascalcase against expected values
for a small matrix (e.g., inputs with hyphens, spaces, acronyms,
leading/trailing underscores) so the behavior of UsefulStr and its properties is
validated across variants.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bfa61c27-9ac3-4000-82d8-b281b099ff69
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
fastapi_code_generator/parser.pypyproject.tomltests/test_parser.py
💤 Files with no reviewable changes (1)
- pyproject.toml
35901fe to
499a328
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #565 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 1204 1244 +40
Branches 126 129 +3
=========================================
+ Hits 1204 1244 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
fastapi_code_generator/parser.py (1)
545-607:⚠️ Potential issue | 🟠 MajorDon't let multipart overwrite an existing body argument.
When a request body contains both JSON and multipart content,
arguments[0]depends on dict order, so one of the request payloads is silently dropped. The new mixed-content test only checksrequest_body_fields, so this regression is currently unguarded. Either reject mixed body types explicitly or preserve both pieces in_temporary_operationinstead of overwriting_request.Possible guard
if 'multipart/form-data' in request_body.content: ... - self._temporary_operation['_request'] = arguments[0] if arguments else None + if len(arguments) > 1: + raise ValueError("Mixed request-body content types are not supported") + self._temporary_operation['_request'] = arguments[0] if arguments else None🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@fastapi_code_generator/parser.py` around lines 545 - 607, The code currently lets a later multipart/form-data branch overwrite an earlier JSON body because _temporary_operation['_request'] is set to arguments[0] after iterating media types; fix by detecting mixed body content inside the loop and either (A) reject mixed JSON+multipart bodies with a clear exception (e.g. raise ValueError including request name) when you encounter a JSON body and later a multipart media_type, or (B) preserve both by storing all body-like arguments (replace _temporary_operation['_request'] = arguments[0] with _temporary_operation['_request'] = arguments if len(arguments) > 1 else arguments[0]) and adjust downstream code to handle a list; implement the chosen approach near the end of the method where arguments is assembled and reference Argument, _get_upload_file_type, request_body, media_type, and _temporary_operation to locate changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@fastapi_code_generator/parser.py`:
- Around line 67-82: The initial re.sub in camelcase currently deletes
characters across delimiters and mangles inputs like "sample_name"; change the
cleaning step in camelcase (used by pascalcase) to normalize non-alphanumeric
runs instead of removing surrounding word characters — e.g., replace sequences
of non-alphanumeric characters with a single delimiter/space (use a pattern like
r"[^A-Za-z0-9]+") on str(value') so subsequent re.sub(r"[\-_\.\s]([a-z])",
_uppercase_group, ...) can correctly uppercase the following letter; keep
pascalcase calling camelcase and then capitalizing the first character.
---
Outside diff comments:
In `@fastapi_code_generator/parser.py`:
- Around line 545-607: The code currently lets a later multipart/form-data
branch overwrite an earlier JSON body because _temporary_operation['_request']
is set to arguments[0] after iterating media types; fix by detecting mixed body
content inside the loop and either (A) reject mixed JSON+multipart bodies with a
clear exception (e.g. raise ValueError including request name) when you
encounter a JSON body and later a multipart media_type, or (B) preserve both by
storing all body-like arguments (replace _temporary_operation['_request'] =
arguments[0] with _temporary_operation['_request'] = arguments if len(arguments)
> 1 else arguments[0]) and adjust downstream code to handle a list; implement
the chosen approach near the end of the method where arguments is assembled and
reference Argument, _get_upload_file_type, request_body, media_type, and
_temporary_operation to locate changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 084be36f-6c86-4aa5-8d24-ddffbebd2315
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
fastapi_code_generator/parser.pypyproject.tomltests/test_parser.py
💤 Files with no reviewable changes (1)
- pyproject.toml
499a328 to
ac52746
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_parser.py (1)
28-44: Consider expandingUsefulStrcase matrix with delimiter-heavy inputs.Adding cases like
pet-id,pet.id, and{petId}here would better guardcamelcase/pascalcasebehavior for the naming patterns this PR targets.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_parser.py` around lines 28 - 44, The current test matrix for UsefulStr (attributes snakecase, camelcase, pascalcase) misses delimiter-heavy inputs; update the parametrized cases in test_useful_str_case_helpers_match_legacy_stringcase_behavior to include examples like "pet-id", "pet.id", and "{petId}" (and their expected snake/camel/pascal outputs) so UsefulStr.snakecase, UsefulStr.camelcase, and UsefulStr.pascalcase are verified for hyphen, dot, and brace-wrapped camel inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/test_parser.py`:
- Around line 28-44: The current test matrix for UsefulStr (attributes
snakecase, camelcase, pascalcase) misses delimiter-heavy inputs; update the
parametrized cases in
test_useful_str_case_helpers_match_legacy_stringcase_behavior to include
examples like "pet-id", "pet.id", and "{petId}" (and their expected
snake/camel/pascal outputs) so UsefulStr.snakecase, UsefulStr.camelcase, and
UsefulStr.pascalcase are verified for hyphen, dot, and brace-wrapped camel
inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b354f4e-f3ac-46b3-a0a2-5c39dee425b7
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
fastapi_code_generator/parser.pypyproject.tomltests/test_parser.py
💤 Files with no reviewable changes (1)
- pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
- fastapi_code_generator/parser.py
Breaking Change AnalysisResult: No breaking changes detected Reasoning: The This analysis was performed by repository automation using PR labels and the |
Fixes: #481
Summary
stringcasepackage with local case conversion helpers for the behavior used by the parser.stringcasefrom project dependencies and the uv lockfile.Checks
uv run pytest -quv run tox -e fixuv run tox -e typeuv run tox -e pkg_metaSummary by CodeRabbit
Refactor
Tests
Chores