-
-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
FastAPIs `Depends` function expects a callable. get_current_user is returning a callable but its type hint did not reflect this It's just a small change but PyCharm annoyed me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! I have just a small suggestion, since the type hint gets corrected anyways we can also make it as explicit as possible :D
fastapi_keycloak/api.py
Outdated
@@ -221,7 +221,7 @@ def user_auth_scheme(self) -> OAuth2PasswordBearer: | |||
""" | |||
return OAuth2PasswordBearer(tokenUrl=self.token_uri) | |||
|
|||
def get_current_user(self, required_roles: List[str] = None, extra_fields: List[str] = None) -> OIDCUser: | |||
def get_current_user(self, required_roles: List[str] = None, extra_fields: List[str] = None) -> Callable[..., OIDCUser]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type hint can be even more specific :D
def get_current_user(self, required_roles: List[str] = None, extra_fields: List[str] = None) -> Callable[..., OIDCUser]: | |
def get_current_user(self, required_roles: List[str] = None, extra_fields: List[str] = None) -> Callable[[OAuth2PasswordBearer], OIDCUser]: |
fastapi_keycloak/api.py
Outdated
@@ -230,7 +230,7 @@ def get_current_user(self, required_roles: List[str] = None, extra_fields: List[ | |||
extra_fields List[str]: The names of the additional fields you need that are encoded in JWT | |||
|
|||
Returns: | |||
OIDCUser: Decoded JWT content | |||
Callable[..., OIDCUser]: Dependency method which returns the decoded JWT content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callable[..., OIDCUser]: Dependency method which returns the decoded JWT content | |
Callable[[OAuth2PasswordBearer], OIDCUser]: Dependency method which returns the decoded JWT content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Right now we are only allowing |
We can think of supporting this, then we would need to somehow make the |
FastAPIs
Depends
function expects a callable.get_current_user
is returning a callable but its type hint did not reflect this.It's just a small change but PyCharms type checker annoyed me...