Commit Graph

6352 Commits

Author SHA1 Message Date
pre-commit-ci-lite[bot] d82a045a18
🎨 Auto format 2025-12-04 22:47:16 +00:00
g7azazlo d5268d7cf5 Enhance AST inference logging and handle multiple return statements
- Added detailed logging for various failure cases in the `infer_response_model_from_ast` function to aid debugging.
- Modified the logic to collect all return statements, ensuring that inference is skipped if multiple returns are detected.
- Introduced a new test case to verify that functions with multiple return statements correctly return None for inference.
2025-12-05 01:46:24 +03:00
pre-commit-ci-lite[bot] ce0990107d
🎨 Auto format 2025-12-03 22:07:56 +00:00
g7azazlo d6cb86380c Add error handling test for response model creation 2025-12-04 01:06:57 +03:00
pre-commit-ci-lite[bot] 8b175fc15c
🎨 Auto format 2025-12-03 21:59:25 +00:00
g7azazlo 4e6a723160 Merge branch 'feat/ast-response-inference' of https://github.com/g7AzaZLO/fastapi into feat/ast-response-inference 2025-12-04 00:58:32 +03:00
g7azazlo 96468d3972 Add comprehensive tests for response model inference and coverage 2025-12-04 00:58:02 +03:00
pre-commit-ci-lite[bot] fc420a592d
🎨 Auto format 2025-12-03 21:35:29 +00:00
g7azazlo b31dd81f48 Refactor import statements in utils for compatibility with Pydantic V2 2025-12-04 00:34:17 +03:00
g7azazlo 2d0161f183 Merge branch 'feat/ast-response-inference' of https://github.com/g7AzaZLO/fastapi into feat/ast-response-inference 2025-12-04 00:29:53 +03:00
g7azazlo bf90082191 Refactor type inference logic in utils for improved clarity
- Simplified the `_infer_type_from_ast` function by consolidating conditional checks for argument annotations, enhancing readability and maintainability.
- Updated test cases in `tests/test_ast_inference.py` to utilize parameterization for better organization and coverage of edge cases in response model inference.
2025-12-04 00:28:00 +03:00
pre-commit-ci-lite[bot] feffe5b824
🎨 Auto format 2025-12-03 21:00:56 +00:00
g7azazlo e03e232c39 Enhance response model inference and add edge case tests
- Updated the `infer_response_model_from_ast` function to use `textwrap.dedent` for cleaner source code handling.
- Added multiple test cases in `tests/test_ast_inference.py` to cover various edge cases for response model inference, including functions with different return types and argument annotations.
- Improved type inference for functions returning lists and nested dictionaries, ensuring better schema generation.
2025-12-03 23:59:58 +03:00
pre-commit-ci-lite[bot] 482c0d24e2
🎨 Auto format 2025-12-03 20:27:27 +00:00
g7azazlo 7e36726baa Enhance response model inference in APIRoute and utils
- Introduced a new helper function `_contains_response` to check for response types in return annotations, improving the inference logic in `APIRoute`.
- Updated the `infer_response_model_from_ast` function to prevent model creation when all fields are of type `Any`, ensuring better type information and avoiding unnecessary overrides.
2025-12-03 23:26:27 +03:00
g7azazlo 65a9b03c57 Enhance response model inference logic in APIRoute and utils
- Updated the response model inference in APIRoute to check for return annotations before inferring the model from the endpoint's source code.
- Added type ignore comments in utils for better type checking compatibility.
- Specified the type of nodes_to_visit in the infer_response_model_from_ast function for improved clarity.
2025-12-03 23:05:01 +03:00
pre-commit-ci-lite[bot] 0a97de688f
🎨 Auto format 2025-12-03 19:48:04 +00:00
g7azazlo 0ecef0ce71 Refactor code style and improve readability in utils and test files
- Removed unnecessary blank lines and improved formatting for better readability in `fastapi/utils.py`.
- Consolidated return statements in test cases to a single line for consistency in `tests/test_ast_inference.py`.
- Enhanced the structure of dictionary returns in endpoint functions for clarity.
2025-12-03 22:46:52 +03:00
g7azazlo 6201559a1c Merge branch 'feat/ast-response-inference' of https://github.com/g7AzaZLO/fastapi into feat/ast-response-inference 2025-12-03 22:46:32 +03:00
g7azazlo 02493746e2 Refine response model inference logic in APIRoute
- Updated the response model inference to handle cases where the model is None or not a subclass of BaseModel or a dataclass.
- Enhanced the logic to infer the response model from the endpoint function's source code when necessary, improving schema generation accuracy.
2025-12-03 22:39:01 +03:00
pre-commit-ci-lite[bot] 95d5b080a2
🎨 Auto format 2025-12-03 19:19:46 +00:00
g7azazlo 5246f7c3ad Add new database-related endpoints and enhance schema validation in tests
- Introduced two new endpoints: "/db/direct_return" and "/db/dict_construction" to simulate database interactions.
- Added a FakeDB class to mock database behavior for testing purposes.
- Enhanced test cases to validate the OpenAPI schema for the new endpoints, ensuring correct response structure and types.
2025-12-03 22:15:49 +03:00
g7azazlo 40af1b90c3 Enhance response model inference and improve error handling
- Updated the response model inference logic in "APIRoute" to check for "None" before validating against "BaseModel".
- Refined the "infer_response_model_from_ast" function to handle nested function definitions and invalid dictionary keys, ensuring robust schema generation.
- Added new test cases for edge scenarios to validate the inference behavior.
2025-12-03 22:06:15 +03:00
g7azazlo 72b210209b Implement response model inference from endpoint function source code
- Added "infer_response_model_from_ast" function to analyze endpoint functions and infer Pydantic models from returned dictionary literals or variable assignments.

- Updated "APIRoute" to utilize the new inference method when the specified response model is not a subclass of "BaseModel"
2025-12-03 21:44:57 +03:00
Sebastián Ramírez c57ac7bdf3 🔖 Release version 0.123.5 2025-12-02 22:06:25 +01:00
github-actions[bot] 3c440c762a 📝 Update release notes
[skip ci]
2025-12-02 20:58:53 +00:00
Lie Ryan 9824486616
Allow using dependables with `functools.partial()` (#9753)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 20:58:30 +00:00
github-actions[bot] aee8e78078 📝 Update release notes
[skip ci]
2025-12-02 17:33:22 +00:00
Nils-Hero Lindemann f4a17b7568
🌐 Sync German docs (#14367)
* Sync with #14217

* Sync with #14359

* Sync with #13786

* Sync with #14070

* Sync with #14120

* Sync with #14211

* Sync with #14405

* "to deploy" -> "deployen"

The LLM used that translation a lot ithis convinced me that "deployen" it is the better word. "bereitstellen" (or "ausliefern") is still used for "to serve".

---------

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
2025-12-02 18:32:56 +01:00
github-actions[bot] 4ade6d62e2 📝 Update release notes
[skip ci]
2025-12-02 17:23:36 +00:00
[object Object] 1c1e584abd
Add support for wrapped functions (e.g. `@functools.wraps()`) used with forward references (#5077)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 18:23:14 +01:00
github-actions[bot] 930b27e5fa 📝 Update release notes
[skip ci]
2025-12-02 17:00:02 +00:00
Victorien 80d69ae0bb
🐛 Fix optional sequence handling with new union syntax from Python 3.10 (#14430)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 16:59:38 +00:00
github-actions[bot] cff2236dac 📝 Update release notes
[skip ci]
2025-12-02 16:49:12 +00:00
Sebastián Ramírez a79ae3d66f
🔥 Remove dangling extra condiitonal no longer needed (#14435) 2025-12-02 16:48:46 +00:00
github-actions[bot] f636513390 📝 Update release notes
[skip ci]
2025-12-02 13:43:52 +00:00
Sebastián Ramírez 247ef32e79
♻️ Refactor internals, update `is_coroutine` check to reuse internal supported variants (unwrap, check class) (#14434) 2025-12-02 13:43:31 +00:00
github-actions[bot] 13a98c9988 📝 Update release notes
[skip ci]
2025-12-02 13:34:45 +00:00
Matthew Martin 73c411e1b9
Handle wrapped dependencies (#9555)
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 14:34:19 +01:00
Sebastián Ramírez 4976568fc7 🔖 Release version 0.123.4 2025-12-02 11:47:05 +01:00
github-actions[bot] fb30cc2f50 📝 Update release notes
[skip ci]
2025-12-02 09:22:35 +00:00
Vincent Grafé f95a174288
🐛 Fix OpenAPI schema support for computed fields when using `separate_input_output_schemas=False` (#13207)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: svlandeg <sofie.vanlandeghem@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 09:22:08 +00:00
github-actions[bot] 5126e099bd 📝 Update release notes
[skip ci]
2025-12-02 09:11:52 +00:00
Motov Yurii dcf0299195
📝 Fix docstring of `servers` parameter (#14405)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 09:11:29 +00:00
Sebastián Ramírez c516c9904b 🔖 Release version 0.123.3 2025-12-02 08:42:22 +01:00
github-actions[bot] b49c05ec22 📝 Update release notes
[skip ci]
2025-12-02 07:24:31 +00:00
Motov Yurii 015b4fae9c
🐛 Fix Query\Header\Cookie parameter model alias (#14360)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 07:24:09 +00:00
github-actions[bot] eead41bf4c 📝 Update release notes
[skip ci]
2025-12-02 07:10:50 +00:00
Motov Yurii 0f613d9051
🐛 Fix optional sequence handling in `serialize sequence value` with Pydantic V2 (#14297)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 08:10:27 +01:00
Sebastián Ramírez 3c54a8f07b 🔖 Release version 0.123.2 2025-12-02 06:31:27 +01:00