From bd2acbcabbb5577013c2207778e76595fb3aa0e9 Mon Sep 17 00:00:00 2001 From: Richard Hoekstra Date: Sat, 13 Jun 2020 09:08:08 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Export=20OAuth2PasswordRequestFormS?= =?UTF-8?q?trict=20from=20security=20(#1462)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update __init__.py Fixes an import error: from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestFormStrict ImportError: cannot import name 'OAuth2PasswordRequestFormStrict' * Simplify import of OAuth2PasswordRequestFormStrict * Simplify import of OAuth2PasswordRequestFormStrict --- fastapi/security/__init__.py | 1 + tests/test_security_oauth2.py | 3 +-- tests/test_security_oauth2_optional.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fastapi/security/__init__.py b/fastapi/security/__init__.py index 37bf213c1..ad727742c 100644 --- a/fastapi/security/__init__.py +++ b/fastapi/security/__init__.py @@ -11,6 +11,7 @@ from .oauth2 import ( OAuth2AuthorizationCodeBearer, OAuth2PasswordBearer, OAuth2PasswordRequestForm, + OAuth2PasswordRequestFormStrict, SecurityScopes, ) from .open_id_connect_url import OpenIdConnect diff --git a/tests/test_security_oauth2.py b/tests/test_security_oauth2.py index 266dab6e5..6c513039f 100644 --- a/tests/test_security_oauth2.py +++ b/tests/test_security_oauth2.py @@ -1,7 +1,6 @@ import pytest from fastapi import Depends, FastAPI, Security -from fastapi.security import OAuth2 -from fastapi.security.oauth2 import OAuth2PasswordRequestFormStrict +from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict from fastapi.testclient import TestClient from pydantic import BaseModel diff --git a/tests/test_security_oauth2_optional.py b/tests/test_security_oauth2_optional.py index 06967bd76..c2c9764b0 100644 --- a/tests/test_security_oauth2_optional.py +++ b/tests/test_security_oauth2_optional.py @@ -2,8 +2,7 @@ from typing import Optional import pytest from fastapi import Depends, FastAPI, Security -from fastapi.security import OAuth2 -from fastapi.security.oauth2 import OAuth2PasswordRequestFormStrict +from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict from fastapi.testclient import TestClient from pydantic import BaseModel