Custom Params doc has code that doesn't work with Python 3.11? #793
Answered by uriyyo
bjornhansen asked this question in Q&A
-
| When I paste the example code from the documentation (Advanced User Guide --> Custom Params) into VSCode, Pylance is giving the error: Am I doing something wrong? Is this a Python version thing? Or is this code example incorrect? As of this writing, the example code is: from typing import List from fastapi import FastAPI from pydantic import BaseModel, EmailStr, Field from fastapi_pagination import Page, add_pagination, paginate Page = Page.with_custom_options( size=Field(100, ge=1, le=500), ) app = FastAPI() add_pagination(app) class UserOut(BaseModel): name: str email: EmailStr users: List[UserOut] = [] @app.get("/users") def get_users() -> Page[UserOut]: return paginate(users) |
Beta Was this translation helpful? Give feedback.
Answered by uriyyo Aug 23, 2023
Replies: 1 comment 1 reply
-
| @bjornhansen It's VS issue cause |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by bjornhansen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bjornhansen It's VS issue cause
with_custom_optionsreturns a new type and VS can't resolve it.