-
-
Notifications
You must be signed in to change notification settings - Fork 306
wip: add pydantic support #1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
for more information, see https://pre-commit.ci
CodSpeed Performance ReportMerging #1247 will not alter performanceComparing Summary
Footnotes |
# Mixed parameters | ||
@app.put("/users/:user_id") | ||
def update_user( | ||
user: User, # Body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it merely restates what is already obvious from the code. The parameter type User
and its position as the first parameter in a route handler already indicate that it's a request body. According to the effective comments rule, comments should not restate what can be understood from the code itself.
🔍 This comment matches your effective_comments.mdc
rule.
user: User, # Body | |
user: User, |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
@app.put("/users/:user_id") | ||
def update_user( | ||
user: User, # Body | ||
user_id: int = Path(...), # Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it merely restates what is already obvious from the code. The use of Path(...)
already clearly indicates this is a path parameter. According to the effective comments rule, comments should not restate what can be understood from the code itself.
🔍 This comment matches your effective_comments.mdc
rule.
user_id: int = Path(...), # Path | |
user_id: int = Path(...), |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
def update_user( | ||
user: User, # Body | ||
user_id: int = Path(...), # Path | ||
notify: bool = Query(True), # Query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it merely restates what is already obvious from the code. The use of Query(True)
already clearly indicates this is a query parameter. According to the effective comments rule, comments should not restate what can be understood from the code itself.
🔍 This comment matches your effective_comments.mdc
rule.
notify: bool = Query(True), # Query | |
notify: bool = Query(True), |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
user: User, # Body | ||
user_id: int = Path(...), # Path | ||
notify: bool = Query(True), # Query | ||
x_source: Optional[str] = Header(None, alias="X-Source") # Header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it merely restates what is already obvious from the code. The use of Header(None)
already clearly indicates this is a header parameter. According to the effective comments rule, comments should not restate what can be understood from the code itself.
🔍 This comment matches your effective_comments.mdc
rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
@app.put("/items/:item_id") | ||
def update_item( | ||
user_data: CreateUserRequest, # Request body (JSON) | ||
item_id: int = Path(..., description="Item ID"), # Path parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it merely restates that this is a path parameter, which is already evident from the code using Path(...). The type annotation and description already make it clear this is a path parameter without needing an additional comment.
🔍 This comment matches your effective_comments.mdc
rule.
item_id: int = Path(..., description="Item ID"), # Path parameter | |
item_id: int = Path(..., description="Item ID"), |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
notify: bool = Query(True, description="Send notifications"), # Query parameter | ||
priority: int = Query(1, description="Priority level"), # Query parameter | ||
x_source: Optional[str] = Header(None, alias="X-Source"), # Header parameter | ||
x_trace: Optional[str] = Header(None, alias="X-Trace-ID"), # Header parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant as it only states that this is a header parameter, which is already evident from the code using Header(). The type annotation and Header usage make this comment unnecessary.
🔍 This comment matches your effective_comments.mdc
rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
Description
This PR fixes #
Summary
This PR does....
PR Checklist
Please ensure that:
Pre-Commit Instructions:
High-level PR Summary
This PR adds Pydantic support to the Robyn web framework, introducing a more modern, type-safe parameter parsing system. The implementation includes new parameter types (
Query
,Path
,Header
,Form
) that enable automatic type conversion, validation, and better developer experience. The PR adds the necessary integration with Pydantic models for request body validation, comprehensive documentation inADVANCED_PARAMS.md
, example applications, and integration tests. The router has been modified to try advanced parameter parsing first before falling back to the original Robyn parameter handling logic, ensuring backward compatibility.⏱️ Estimated Review Time: 1h 30m
💡 Review Order Suggestion
robyn/advanced_params.py
robyn/router.py
robyn/__init__.py
ADVANCED_PARAMS.md
examples/advanced_params_example.py
integration_tests/test_advanced_params.py
quick_start_example.py
pyproject.toml
Review by RecurseML
🔍 Review performed on 7bbfa0a..b15cabb
✅ Files analyzed, no issues (5)
•
robyn/advanced_params.py
•
integration_tests/test_advanced_params.py
•
examples/advanced_params_example.py
•
robyn/__init__.py
•
robyn/router.py