Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.7k
🎨 Fix types for lifespan, upgrade Starlette to 0.26.1#9245
Conversation
github-actionsbot commentedMar 12, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
📝 Docs preview for commit2e373fa at:https://640dbed4fbc9f768d2b35cd4--fastapi.netlify.app |
adriangb commentedMar 12, 2023
You also need to add |
tiangolo commentedMar 14, 2023
Good point, thanks@adriangb! Trying it locally I realized I had to redefine |
adriangb commentedMar 14, 2023
Hmm I’m surprised the |
📝 Docs preview for commit4578cfb at:https://640fd2b293def71708f521d2--fastapi.netlify.app |
tiangolo commentedMar 14, 2023
I'm trying with this example: fromcollections.abcimportAsyncGeneratorfromcontextlibimportasynccontextmanagerfromfastapiimportFastAPI@asynccontextmanagerasyncdeflifespan(_:FastAPI)->AsyncGenerator[None,None]: ...yield ...app=FastAPI(lifespan=lifespan) And I get this error: ...I guess it would be fine for external things to have |
adriangb commentedMar 14, 2023
Weird, we even have a test in Starlette:https://github.com/encode/starlette/blob/8965f8849977b5752e415722a83aa00049f80ff3/tests/test_applications.py#L539-L550 |
tiangolo commentedMar 14, 2023
Ah, yeah, the error is not in the lifespan, but that the class doesn't have the custom attributes |
🎨 Fix types for lifespan, depends onKludex/starlette#2077