mongkok / fastapi-debug-toolbar

A debug toolbar for FastAPI.
https://fastapi-debug-toolbar.domake.io
BSD 3-Clause "New" or "Revised" License
140 stars 14 forks source link

type error : running in python 3.8 #47

Closed kitrio closed 9 months ago

kitrio commented 9 months ago

OS: windows 10 python 3.8 fastapi 0.109.1

Project's toml file, it support python 3.8.

but type error occurred:

this error not showing 0.5 version.

app.add_middleware(
    DebugToolbarMiddleware,
    panels=["debug_toolbar.panels.sqlalchemy.SQLAlchemyPanel"],
)

this is stack trace.


    from debug_toolbar.middleware import DebugToolbarMiddleware

  File "C:\proj\venv\lib\site-packages\debug_toolbar\middleware.py", line 16, in <module>
    from debug_toolbar.api import render_panel

  File "C:\proj\venv\lib\site-packages\debug_toolbar\api.py", line 6, in <module>
    from debug_toolbar.toolbar import DebugToolbar

  File "C:\proj\venv\lib\site-packages\debug_toolbar\toolbar.py", line 12, in <module>
    from debug_toolbar.settings import DebugToolbarSettings

  File "C:\proj\venv\lib\site-packages\debug_toolbar\settings.py", line 12, in <module>
    class DebugToolbarSettings(BaseSettings):

  File "C:\proj\venv\lib\site-packages\pydantic\_internal\_model_construction.py", line 181, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)

  File "C:\proj\venv\lib\site-packages\pydantic\_internal\_model_construction.py", line 426, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)

  File "C:\proj\venv\lib\site-packages\pydantic\_internal\_fields.py", line 120, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)

  File "C:\proj\venv\lib\site-packages\pydantic\_internal\_typing_extra.py", line 212, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)

  File "C:\proj\venv\lib\site-packages\pydantic\_internal\_typing_extra.py", line 224, in eval_type_lenient
    return typing._eval_type(value, globalns, localns)  # type: ignore

  File "C:\Users\rio\AppData\Local\Programs\Python\Python38\lib\typing.py", line 270, in _eval_type
    return t._evaluate(globalns, localns)

  File "C:\Users\rio\AppData\Local\Programs\Python\Python38\lib\typing.py", line 518, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
TypeError: 'type' object is not subscriptable```
mongkok commented 9 months ago

Hey @kitrio , this is a known issue from Pydantic, see https://github.com/pydantic/pydantic/issues/7873. I've removed future annotations from Pydantic BaseSettings, please check the new release.

I close the issue, if you have any questions please let me know.