Skip to content
This repository was archived by the owner on Nov 10, 2024. It is now read-only.
This repository was archived by the owner on Nov 10, 2024. It is now read-only.

[BUG] Annotated is not supported in class based views #177

Description

@mattmess1221

The new way to declare a dependency in FastAPI 0.95 is to use arg: Annotated[type, Depends(func)] = default. Using this on a cbv decorated class attribute does not behave as expected. The cbv seems to treat the attribute as if it wasn't annotated at all.

Example:

def my_dependency():
  return "Dependency"

@cbv(router)
class MyView:
  dep: Annotated[str, Depends(my_dependency)
  # behaves as if
  dep: str

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions