Codebuff Contributor
6d404bca9a
Fix mypy/ty by using _evaluate, fix dict type args, ignore deprecation warning
- Keep ForwardRef._evaluate (recognized by mypy/ty typeshed)
- Fix class _LenientNamespace(dict) -> _LenientNamespace(dict[str, Any])
- Use frozenset() instead of set() for recursive_guard
- Ignore ForwardRef._evaluate deprecation warning in pytest config
3 weeks ago
Codebuff Contributor
4c998f64db
Fix pre-commit and Python 3.14 test CI failures
- Remove duplicate _resolve_forward_ref_lenient function
- Use ForwardRef.evaluate() instead of deprecated _evaluate()
- Use frozenset() instead of set() for recursive_guard parameter
- Add noqa for E402 in test file (deliberate late import)
3 weeks ago
Codebuff Contributor
477ebee8d2
ruff format fix
3 weeks ago
Codebuff Contributor
e20b2497f3
Fix: type_params needed on Python 3.13+ too
3 weeks ago
Codebuff Contributor
afd043b03e
Fix ForwardRef._evaluate() missing type_params for Python 3.14+
Python 3.14 added a new 'type_params' parameter to ForwardRef._evaluate()
(PEP 695). Failing to pass it triggers a DeprecationWarning, which is
treated as error by FastAPI's test suite (-W error). Pass type_params=()
on Python 3.14+ to silence the warning.
3 weeks ago
Codebuff Contributor
63613e0b83
Fix ForwardRef._evaluate() keyword-only argument for Python 3.13+
In Python 3.13+, ForwardRef._evaluate() requires 'recursive_guard'
as a keyword-only argument. Pass it as keyword to support both
older and newer Python versions.
3 weeks ago
Codebuff Contributor
becafff6b5
Fix Annotated forward ref resolution with from __future__ import annotations
When using rom __future__ import annotations, annotations are stored as
strings. If Annotated[SomeClass, Depends()] references a class defined
after the route decorator, the forward reference could not be resolved at
decoration time.
FastAPI's evaluate_forwardref() does not raise on unresolvable references
- it returns the raw ForwardRef object. The existing code only handled the
string-to-ForwardRef conversion but did not check whether resolution
actually succeeded, allowing an unresolvable ForwardRef to leak into the
type annotation. This caused Pydantic to fail with
'class-not-fully-defined' errors and the Depends metadata to be lost.
The fix adds a fallback: when evaluate_forwardref() returns a ForwardRef
(rather than the resolved type) and the annotation string is Annotated-
shaped, a lenient resolution evaluates the annotation with a namespace
that maps undefined names to Any. This preserves the Annotated structure
so FastAPI can extract the Depends metadata.
3 weeks ago
dependabot[bot]
5d5666bec5
⬆ Bump ty from 0.0.21 to 0.0.34 ( #15443 )
Signed-off-by: dependabot[bot] <[email protected] >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: svlandeg <[email protected] >
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
3 weeks ago
Sofie Van Landeghem
7815a32f2e
⬆️ Update Pydantic v2 code to address deprecations ( #15101 )
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 month ago
Sofie Van Landeghem
98b269b51e
👷 Add `ty` to precommit ( #15091 )
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <[email protected] >
3 months ago
Sebastián Ramírez
749cefdeb1
✨ Add support for streaming JSON Lines and binary data with `yield` ( #15022 )
3 months ago
Sebastián Ramírez
ad4e8e0060
➖ Drop support for Python 3.9 ( #14897 )
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
4 months ago
Sebastián Ramírez
25270fcee0
♻️ Simplify reading files in memory, do it sequentially instead of (fake) parallel ( #14884 )
4 months ago
Sebastián Ramírez
2e7d3754cd
♻️ Refactor and simplify Pydantic v2 (and v1) compatibility internal utils ( #14862 )
4 months ago
Sebastián Ramírez
d59fbc3494
♻️ Refactor internals, simplify Pydantic v2/v1 utils, `create_model_field`, better types for `lenient_issubclass` ( #14860 )
4 months ago
Sebastián Ramírez
cf55bade7e
♻️ Simplify internals, remove Pydantic v1 only logic, no longer needed ( #14857 )
4 months ago
Kanetsuna Masaya
c5fd75a321
🐛 Fix using `Json[list[str]]` type (issue #10997 ) ( #14616 )
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
4 months ago
Albin Skott
97145588f5
✨ Add support for PEP695 `TypeAliasType` ( #13920 )
Co-authored-by: lokidev <[email protected] >
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yurii Motov <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
4 months ago
Jonathan Fulton
b49435becd
✨ Allow `Response` type hint as dependency annotation ( #14794 )
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
4 months ago
Mickaël Guérin
09f5941f0e
🐛 Fix TYPE_CHECKING annotations for Python 3.14 (PEP 649) ( #14789 )
4 months ago
Anton
41352de24c
🚸 Improve error message for invalid query parameter type annotations ( #14479 )
Co-authored-by: Anton.D <[email protected] >
Co-authored-by: Motov Yurii <[email protected] >
4 months ago
Motov Yurii
f3f498100f
👷 Run mypy by pre-commit ( #14806 )
Co-authored-by: Sebastián Ramírez <[email protected] >
4 months ago
Sebastián Ramírez
e300630551
➖ Drop support for `pydantic.v1` ( #14609 )
5 months ago
Sebastián Ramírez
535b5daa31
🔊 Add a custom `FastAPIDeprecationWarning` ( #14605 )
5 months ago
Sebastián Ramírez
6e42bcd8ce
🔊 Add deprecation warnings when using `pydantic.v1` ( #14583 )
6 months ago
Sebastián Ramírez
e2cd8a4201
➖ Drop support for Pydantic v1, keeping short temporary support for Pydantic v2's `pydantic.v1` ( #14575 )
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
6 months ago
Sebastián Ramírez
1c4fc96c91
♻️ Upgrade internal syntax to Python 3.9+ 🎉 ( #14564 )
6 months ago
Motov Yurii
d86c47477e
🐛 Fix parameter aliases ( #14371 )
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Sebastián Ramírez
7ba042e069
🐛 Fix support for `if TYPE_CHECKING`, non-evaluated stringified annotations ( #14485 )
6 months ago
Sebastián Ramírez
0b5fa563cd
🐛 Fix OAuth2 scopes in OpenAPI in extra corner cases, parent dependency with scopes, sub-dependency security scheme without scopes ( #14459 )
6 months ago
chaen
861598b4e3
🐛 Fix evaluating stringified annotations in Python 3.10 ( #11355 )
Co-authored-by: Sofie Van Landeghem <[email protected] >
Co-authored-by: svlandeg <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Sebastián Ramírez
bba4d4c95e
🐛 Fix support for functools wraps and partial combined, for async and regular functions and classes in path operations and dependencies ( #14448 )
Co-authored-by: Yurii Motov <[email protected] >
6 months ago
[object Object]
1c1e584abd
✨ Add support for wrapped functions (e.g. `@functools.wraps()`) used with forward references ( #5077 )
Co-authored-by: Yurii Karabas <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Motov Yurii
015b4fae9c
🐛 Fix Query\Header\Cookie parameter model alias ( #14360 )
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Motov Yurii
de5bec637c
🐛 Fix parsing extra non-body parameter list ( #14356 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Motov Yurii
6cf40df24d
🐛 Fix parsing extra `Form` parameter list ( #14303 )
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
ad hoc
d68c066246
🐛 Fix support for form values with empty strings interpreted as missing (`None` if that's the default), for compatibility with HTML forms ( #13537 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: Yurii Motov <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
6 months ago
Sebastián Ramírez
7fbd30460f
🐛 Cache dependencies that don't use scopes and don't have sub-dependencies with scopes ( #14419 )
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
6 months ago
Kristján Valur Jónsson
378ad688b7
🐛 Fix hierarchical security scope propagation ( #5624 )
Co-authored-by: Sebastián Ramírez <[email protected] >
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: svlandeg <[email protected] >
Co-authored-by: Sofie Van Landeghem <[email protected] >
6 months ago
Sebastián Ramírez
85701631a0
♻️ Make the result of `Depends()` and `Security()` hashable, as a workaround for other tools interacting with these internal parts ( #14372 )
7 months ago
luzzodev
282f372eda
🐛 Fix `Depends(func, scope='function')` for top level (parameterless) dependencies ( #14301 )
7 months ago
Sebastián Ramírez
ac438b9934
✨ Add support for dependencies with scopes, support `scope="request"` for dependencies with `yield` that exit before the response is sent ( #14262 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
7 months ago
Motov Yurii
496de1816a
🐛 Fix security schemes in OpenAPI when added at the top level app ( #14266 )
Co-authored-by: Sebastián Ramírez <[email protected] >
7 months ago
Sebastián Ramírez
dcfb8b9dda
♻️ Reduce internal cyclic recursion in dependencies, from 2 functions calling each other to 1 calling itself ( #14256 )
7 months ago
Sebastián Ramírez
bb88a0f94a
♻️ Refactor internals of dependencies, simplify code and remove `get_param_sub_dependant` ( #14255 )
7 months ago
Sebastián Ramírez
c144f9fbd3
♻️ Refactor internals of dependencies, simplify using dataclasses ( #14254 )
7 months ago
Sofie Van Landeghem
d8c691f7f0
🐛 Fix internal Pydantic v1 compatibility (warnings) for Python 3.14 and Pydantic 2.12.1 ( #14186 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <[email protected] >
8 months ago
Sebastián Ramírez
d34918abf0
✨ Add support for `from pydantic.v1 import BaseModel`, mixed Pydantic v1 and v2 models in the same app ( #14168 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
8 months ago
Thomas LÉVEIL
44fc67632b
🐛 Fix validation error when `File` is declared after `Form` parameter ( #11194 )
Co-authored-by: Sebastián Ramírez <[email protected] >
9 months ago
Robert Hofer
b51ec36f2e
✨ Allow `None` as return type for bodiless responses ( #9425 )
Co-authored-by: Sebastián Ramírez <[email protected] >
9 months ago