Sebastián Ramírez
7fe315c21a
🐛 Refactor router route building to make it thread-safe, mainly relevant for tests running in parallel threads (uncommon) ( #16013 )
3 weeks ago
Sebastián Ramírez
eb75fd078e
🐛 Fix frontend fallback support for doted paths like `/users/john.doe` ( #16011 )
3 weeks ago
Sebastián Ramírez
319be508ce
✨ Support dependencies in `app.frontend()`, e.g. for automatic cookie authentication for the frontend ( #15908 )
1 month ago
Sebastián Ramírez
b790e14cb6
♻️ Make `app.frontend()` return 404 for methods other than `GET` or `HEAD` with no static file matches ( #15863 )
1 month ago
Sebastián Ramírez
2260afaf43
🐛 Fix failing test, update format for raised errors ( #15804 )
2 months ago
Sebastián Ramírez
4d3dc78b26
✨ Add support for `app.frontend("/", directory="dist")` and `router.frontend("/", directory="dist")` ( #15800 )
2 months ago
Sebastián Ramírez
6ac122071d
✨ Add `iter_route_contexts()` for advanced use cases that used to use `router.routes` (e.g. Jupyverse) ( #15785 )
2 months ago
Sebastián Ramírez
b78c82262f
🚨 Fix typing checks for APIRoute ( #15765 )
2 months ago
Sebastián Ramírez
d8aad201eb
🐛 Fix bug, allow empty path in path operation in prefixless router ( #15763 )
2 months ago
Sebastián Ramírez
8e1d774cef
♻️ Refactor internals to preserve `APIRouter` and `APIRoute` instances ( #15745 )
2 months 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 months 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] >
5 months ago
Sebastián Ramírez
8a9258b169
🐛 Fix, avoid yield from a TaskGroup, only as an async context manager, closed in the request async exit stack ( #15038 )
5 months ago
Sebastián Ramírez
2238155844
✨ Add support for Server Sent Events ( #15030 )
5 months ago
Sebastián Ramírez
749cefdeb1
✨ Add support for streaming JSON Lines and binary data with `yield` ( #15022 )
5 months ago
Sebastián Ramírez
22354a2530
🔒 ️ Add `strict_content_type` checking for JSON requests ( #14978 )
5 months ago
Sebastián Ramírez
590a5e5355
✨ Serialize JSON response with Pydantic (in Rust), when there's a Pydantic return type or response model ( #14962 )
5 months ago
pre-commit-ci-lite[bot]
6240dc105a
🎨 Auto format
6 months ago
Charisn
d762eb6405
Fix _endpoint_context_cache using id() which risks stale entries and memory leaks
The _endpoint_context_cache in routing.py used id(func) as dict keys to
cache endpoint context (source file, line number, function name) for
error messages. This has two problems:
1. ID reuse after garbage collection. Python id() returns the memory
address of an object. Once an object is garbage collected, its ID can
be reassigned to a newly created object. If an endpoint function were
deallocated and a new function reused the same ID, the cache would
return stale context (wrong file, line, function name) for error
messages.
2. No eviction. The module-level dict grows unboundedly for every unique
endpoint function. In scenarios where FastAPI instances are
dynamically created and destroyed in a single process (e.g., test
suites running hundreds of apps), endpoint functions and their
closures are kept alive indefinitely by the cache, leaking memory.
Fix: replace the plain dict with a weakref.WeakKeyDictionary keyed on
the function object itself. This solves both problems: keys are looked
up by object identity (no ID collision), and entries are automatically
evicted when the endpoint function is garbage collected, allowing the
function and its closure to be reclaimed.
Endpoint functions always support weak references (regular def / async
def), so WeakKeyDictionary is safe for this use case.
6 months ago
Sebastián Ramírez
3da206c06d
🎨 Update internal types for Python 3.10 ( #14898 )
6 months ago
Javier Sánchez Castro
df950111fe
✨ Show a clear error on attempt to include router into itself ( #14258 )
Co-authored-by: Javier Sánchez <[email protected] >
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <[email protected] >
6 months ago
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>
6 months ago
Sebastián Ramírez
d59fbc3494
♻️ Refactor internals, simplify Pydantic v2/v1 utils, `create_model_field`, better types for `lenient_issubclass` ( #14860 )
6 months ago
Sebastián Ramírez
cf55bade7e
♻️ Simplify internals, remove Pydantic v1 only logic, no longer needed ( #14857 )
6 months ago
Sebastián Ramírez
3c49346238
♻️ Refactor internals, cleanup unneeded Pydantic v1 specific logic ( #14856 )
6 months ago
Sebastián Ramírez
f9f7992604
♻️ Re-implement `on_event` in FastAPI for compatibility with the next Starlette, while keeping backwards compatibility ( #14851 )
6 months ago
Sebastián Ramírez
e300630551
➖ Drop support for `pydantic.v1` ( #14609 )
7 months ago
Sebastián Ramírez
535b5daa31
🔊 Add a custom `FastAPIDeprecationWarning` ( #14605 )
7 months ago
Sebastián Ramírez
6e42bcd8ce
🔊 Add deprecation warnings when using `pydantic.v1` ( #14583 )
8 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>
8 months ago
Sebastián Ramírez
1c4fc96c91
♻️ Upgrade internal syntax to Python 3.9+ 🎉 ( #14564 )
8 months ago
Savannah Ostrowski
e1117f7550
🚸 Improve tracebacks by adding endpoint metadata ( #14306 )
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
a79ae3d66f
🔥 Remove dangling extra condiitonal no longer needed ( #14435 )
8 months ago
Sebastián Ramírez
247ef32e79
♻️ Refactor internals, update `is_coroutine` check to reuse internal supported variants (unwrap, check class) ( #14434 )
8 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>
9 months ago
Sebastián Ramírez
d390f2e41f
➕ Migrate internal reference documentation from `typing_extensions.Doc` to `annotated_doc.Doc` ( #14222 )
10 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>
10 months ago
Sebastián Ramírez
e329d78f86
🐛 Fix support for `StreamingResponse`s with dependencies with `yield` or `UploadFile`s, close after the response is done ( #14099 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
10 months ago
secrett2633
c831cdbde2
🐛 Fix `inspect.getcoroutinefunction()` can break testing with `unittest.mock.patch()` ( #14022 )
11 months ago
Tamir Duberstein
a95e91e46e
⬆️ Update mypy to 1.14.1 ( #12970 )
Co-authored-by: Motov Yurii <[email protected] >
Co-authored-by: Sofie Van Landeghem <[email protected] >
Co-authored-by: svlandeg <[email protected] >
Co-authored-by: svlandeg <[email protected] >
11 months ago
Sebastián Ramírez
cad6880fd9
⬆️ Upgrade Starlette supported version range to `>=0.40.0,<0.48.0` ( #13884 )
1 year ago
Timon
97fdbdd0d8
📝 Update exclude-parameters-from-openapi documentation links ( #13600 )
1 year ago
dependabot[bot]
8c94e97c89
⬆ Bump ruff to 0.9.4 ( #13299 )
* ⬆ Bump ruff from 0.6.4 to 0.9.4
Bumps [ruff](https://github.com/astral-sh/ruff ) from 0.6.4 to 0.9.4.
- [Release notes](https://github.com/astral-sh/ruff/releases )
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md )
- [Commits](https://github.com/astral-sh/ruff/compare/0.6.4...0.9.4 )
---
updated-dependencies:
- dependency-name: ruff
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <[email protected] >
* update pre-commit accordingly and make formatting changes
* 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
---------
Signed-off-by: dependabot[bot] <[email protected] >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alejandra <[email protected] >
Co-authored-by: svlandeg <[email protected] >
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 year ago
Felix Fanghaenel
e049fc4ea1
🐛 Fix openapi generation with responses kwarg ( #10895 )
Co-authored-by: flxdot <[email protected] >
Co-authored-by: Sofie Van Landeghem <[email protected] >
Co-authored-by: Sławek Ehlert <[email protected] >
2 years ago
Sebastián Ramírez
aa21814a89
♻️ Refactor deciding if `embed` body fields, do not overwrite fields, compute once per router, refactor internals in preparation for Pydantic models in `Form`, `Query` and others ( #12117 )
2 years ago
Sebastián Ramírez
d08b95ea57
♻️ Rename internal `create_response_field()` to `create_model_field()` as it's used for more than response models ( #12103 )
2 years ago
Sebastián Ramírez
5b7fa3900e
♻️ Refactor and simplify internal data from `solve_dependencies()` using dataclasses ( #12100 )
2 years ago
Pastukhov Nikita
3a4ac24675
🐛 Ensure that `app.include_router` merges nested lifespans ( #9630 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <[email protected] >
Co-authored-by: Sebastián Ramírez <[email protected] >
2 years ago
Sebastián Ramírez
3a3ad5d66d
⬆️ Upgrade version of Ruff and reformat ( #12032 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2 years ago
Aleksei Kotenko
9c80842cea
♻️ Update mypy ( #11049 )
Co-authored-by: Sebastián Ramírez <[email protected] >
2 years ago