Commit Graph

6938 Commits

Author SHA1 Message Date
rijenkii 66dc695071
Replace `dict` by `Mapping` on `HTTPException.headers` (#12997)
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-02-10 11:52:24 +01:00
github-actions[bot] e94028ab60 📝 Update release notes
[skip ci]
2026-02-09 17:39:11 +00:00
Motov Yurii 8fd291465b
🔧 Configure `test` workflow to run tests with `inline-snapshot=review` (#14876) 2026-02-09 18:38:48 +01:00
Sebastián Ramírez fbca586c1d 📝 Update release notes 2026-02-09 18:25:04 +01:00
github-actions[bot] 4e879799dd 📝 Update release notes
[skip ci]
2026-02-09 17:21:32 +00:00
Sebastián Ramírez 0a4033aeee 🔖 Release version 0.128.6 2026-02-09 18:19:22 +01:00
Motov Yurii ed2512a5ec
🐛 Fix `on_startup` and `on_shutdown` parameters of `APIRouter` (#14873)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-09 17:31:57 +01:00
github-actions[bot] 0c0f6332e2 📝 Update release notes
[skip ci]
2026-02-09 15:36:09 +00:00
Motov Yurii 227cb85a03
Fix parameterized tests with snapshots (#14875) 2026-02-09 16:35:43 +01:00
github-actions[bot] cd31576d57 📝 Update release notes
[skip ci]
2026-02-08 10:40:08 +00:00
Sebastián Ramírez 376e108580
🌐 Update translations for zh (update-outdated) (#14843)
Co-authored-by: github-actions[bot] <github-actions[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>
2026-02-08 11:39:41 +01:00
Sebastián Ramírez dedf1409fe 🔖 Release version 0.128.5 2026-02-08 11:20:22 +01:00
github-actions[bot] 79d4dfb37f 📝 Update release notes
[skip ci]
2026-02-08 10:19:07 +00:00
Sebastián Ramírez 9f4ecf562c
Add inline snapshot tests for OpenAPI before changes from Pydantic v2 (#14864) 2026-02-08 10:18:38 +00:00
github-actions[bot] c48539f4c6 📝 Update release notes
[skip ci]
2026-02-07 08:34:59 +00:00
Sebastián Ramírez 2e7d3754cd
♻️ Refactor and simplify Pydantic v2 (and v1) compatibility internal utils (#14862) 2026-02-07 08:34:32 +00:00
Sebastián Ramírez 8eac94bd91 🔖 Release version 0.128.4 2026-02-07 09:12:54 +01:00
github-actions[bot] 58cdfc7f4b 📝 Update release notes
[skip ci]
2026-02-07 08:08:31 +00:00
Sebastián Ramírez d59fbc3494
♻️ Refactor internals, simplify Pydantic v2/v1 utils, `create_model_field`, better types for `lenient_issubclass` (#14860) 2026-02-07 08:08:07 +00:00
Adarsh Bennur a320bc6c27
Merge branch 'master' into fix-issue-13399-form-fields-set 2026-02-07 01:09:08 +05:30
pre-commit-ci-lite[bot] 5afc0c1751
🎨 Auto format 2026-02-06 19:24:37 +00:00
Adarsh Bennur eec089f9a3 Fix coverage: Use inline ternary for Pydantic v1/v2 compatibility
Replaced multi-line if/else blocks with inline ternary expressions to
ensure all code paths are covered in line-based coverage reporting.

The hasattr() check works correctly for both Pydantic versions:
- V2: hasattr returns True, uses model_fields_set
- V1: hasattr returns False, uses __fields_set__

Combined coverage across matrix jobs will now show 100%.
2026-02-07 00:53:35 +05:30
Adarsh Bennur 7a39d5b85f Fix: Use typing_extensions.Annotated for Python 3.8 compatibility
Python 3.8 does not have Annotated in typing module (added in 3.9).
Using typing_extensions ensures tests run on all Python versions.

Added noqa: UP035 to suppress ruff's preference for typing module,
since typing_extensions is required for Python 3.8 support.
2026-02-07 00:38:40 +05:30
github-actions[bot] cc6ced6345 📝 Update release notes
[skip ci]
2026-02-06 19:04:48 +00:00
Sebastián Ramírez cf55bade7e
♻️ Simplify internals, remove Pydantic v1 only logic, no longer needed (#14857) 2026-02-06 19:04:24 +00:00
Adarsh Bennur d7cb6f2538 Fix test ImportError: use local Pydantic version detection instead of internal _compat
Replace `from fastapi._compat import PYDANTIC_V2` with local version
detection to avoid ImportError in redistribute/slim package tests where
fastapi._compat internals are not available.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06 23:50:47 +05:30
Adarsh Bennur 34c0142517 Fix test syntax + ruff issues causing CI matrix failures
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06 23:34:20 +05:30
Adarsh Bennur 3f2e378ff3 Fix: Use typing_extensions.Annotated for Python 3.8 compatibility
Changed import in tests/test_forms_fields_set.py from typing.Annotated
to typing_extensions.Annotated to ensure tests run on Python 3.8.

This fixes the Test / check CI failure and restores coverage to 100%
by allowing the comprehensive coverage tests to execute on all Python
versions in the CI matrix.
2026-02-06 23:31:43 +05:30
Adarsh Bennur ca8b59f52d Fix coverage by adding Query/Header tests to test_forms_fields_set.py
Ensures that _get_multidict_value is fully covered (both FormData and non-FormData paths) to satisfy CI requirements.
2026-02-06 23:31:43 +05:30
Adarsh Bennur 39b4ae0698 Fix: Make fields_set tests compatible with Pydantic v1 and v2
Rewrote test_forms_fields_set.py to work on both Pydantic versions:
- Use PYDANTIC_V2 flag from fastapi._compat
- Use model_fields_set (v2) or __fields_set__ (v1) appropriately
- Removed field_validator which is v2-only
- All tests now run on both versions for full coverage
2026-02-06 23:31:43 +05:30
Adarsh Bennur 3c62970852 Fix: Make test compatible with Pydantic v1 and v2
Add version check to skip test_forms_fields_set.py when Pydantic v1
is installed, since field_validator is a v2-only API.
2026-02-06 23:31:43 +05:30
Adarsh Bennur b82e39d665 Fix: Preserve model_fields_set for Form models (issue #13399)
When using Form() with Pydantic models, FastAPI was preloading default
values and passing them to Pydantic, causing all fields to appear in
model_fields_set even when not provided. This also caused validation
to be enforced on unprovided defaults.

Changes:
- Modified _get_multidict_value() to check if values is FormData
- For FormData, return None for unprovided fields instead of defaults
- This lets Pydantic handle defaults properly and preserve fields_set
- Updated test expectation in test_forms_single_model.py
- Added comprehensive test suite in test_forms_fields_set.py

The fix ensures Form models behave consistently with JSON body models
regarding field tracking and validation.

Closes #13399
2026-02-06 23:31:43 +05:30
github-actions[bot] ac8362c447 📝 Update release notes
[skip ci]
2026-02-06 18:01:30 +00:00
Sebastián Ramírez 3c49346238
♻️ Refactor internals, cleanup unneeded Pydantic v1 specific logic (#14856) 2026-02-06 19:01:05 +01:00
github-actions[bot] 512c3ad88c 📝 Update release notes
[skip ci]
2026-02-06 17:24:56 +00:00
Motov Yurii cba537ab71
🌐 Update translations for fr (outdated pages) (#14839) 2026-02-06 18:24:25 +01:00
github-actions[bot] 2eb454ab04 📝 Update release notes
[skip ci]
2026-02-06 17:24:15 +00:00
Motov Yurii 0f5987b560
🌐 Update translations for tr (outdated and missing) (#14838) 2026-02-06 18:23:48 +01:00
github-actions[bot] 266a3138b5 📝 Update release notes
[skip ci]
2026-02-06 17:18:53 +00:00
Sebastián Ramírez 5a31b37cc7
⬆️ Upgrade development dependencies (#14854) 2026-02-06 17:18:30 +00:00
Sebastián Ramírez 36985f5f25 🔖 Release version 0.128.3 2026-02-06 17:44:11 +01:00
github-actions[bot] 661cdfb8a4 📝 Update release notes
[skip ci]
2026-02-06 16:38:15 +00:00
Sebastián Ramírez f6cc650a12
⬆️ Upgrade Starlette supported version range to `starlette>=0.40.0,<1.0.0` (#14853) 2026-02-06 16:37:37 +00:00
github-actions[bot] 201feedd68 📝 Update release notes
[skip ci]
2026-02-06 15:31:16 +00:00
Sebastián Ramírez 19f13ead4c
👷 Run tests with Starlette from git (#14849) 2026-02-06 16:30:48 +01:00
github-actions[bot] 01e85c03bd 📝 Update release notes
[skip ci]
2026-02-06 15:29:27 +00:00
Sebastián Ramírez 08233d7ffc
🌐 Update translations for ru (update-outdated) (#14834)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-06 16:28:59 +01:00
github-actions[bot] fe8c33ea64 📝 Update release notes
[skip ci]
2026-02-06 15:18:55 +00:00
Sebastián Ramírez f9f7992604
♻️ Re-implement `on_event` in FastAPI for compatibility with the next Starlette, while keeping backwards compatibility (#14851) 2026-02-06 16:18:30 +01:00
github-actions[bot] 8e50c55fd9 📝 Update release notes
[skip ci]
2026-02-06 13:45:47 +00:00