mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 05:15:46 -04:00
🎨 Upgrade typing syntax for Python 3.10 (#14932)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: tiangolo <1326112+tiangolo@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6e5680c7ea
commit
faee822574
@@ -1,5 +1,4 @@
|
||||
from base64 import b64encode
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import FastAPI, Security
|
||||
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||
@@ -12,7 +11,7 @@ security = HTTPBasic(auto_error=False)
|
||||
|
||||
|
||||
@app.get("/users/me")
|
||||
def read_current_user(credentials: Optional[HTTPBasicCredentials] = Security(security)):
|
||||
def read_current_user(credentials: HTTPBasicCredentials | None = Security(security)):
|
||||
if credentials is None:
|
||||
return {"msg": "Create an account first"}
|
||||
return {"username": credentials.username, "password": credentials.password}
|
||||
|
||||
Reference in New Issue
Block a user