Skip to content

Commit 39b51eb

Browse files
committed
修复非Pydantic类型参数为可选字段时的问题
1 parent c956ecf commit 39b51eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backend/app/api/jwt_security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
from datetime import datetime, timedelta
4-
from typing import Any, Optional, Union
4+
from typing import Any, Union
55

66
from fastapi import Depends
77
from fastapi.security import OAuth2PasswordBearer
@@ -38,7 +38,7 @@ def verity_password(plain_password: str, hashed_password: str) -> bool:
3838
return pwd_context.verify(plain_password, hashed_password)
3939

4040

41-
def create_access_token(data: Union[int, Any], expires_delta: Optional[timedelta]) -> str:
41+
def create_access_token(data: Union[int, Any], expires_delta: Union[timedelta, None] = None) -> str:
4242
"""
4343
生成加密 token
4444
:param data: 传进来的值

0 commit comments

Comments
 (0)