Fix ImportError when redis optional dependency not installed

This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
François Voron
2021-12-30 15:47:31 +01:00
gitea-unlock(16/)
parent 925dad5207
commit dc15309b09
octicon-diff(16/tw-mr-1) 2 changed files with 12 additions and 2 deletions

8
fastapi_users/authentication/__init__.py
View File

@@ -1,6 +1,12 @@
from fastapi_users.authentication.authenticator import Authenticator from fastapi_users.authentication.authenticator import Authenticator
from fastapi_users.authentication.backend import AuthenticationBackend from fastapi_users.authentication.backend import AuthenticationBackend
from fastapi_users.authentication.strategy import JWTStrategy, RedisStrategy, Strategy from fastapi_users.authentication.strategy import JWTStrategy, Strategy
try:
from fastapi_users.authentication.strategy import RedisStrategy
except ImportError: # pragma: no cover
pass
from fastapi_users.authentication.transport import ( from fastapi_users.authentication.transport import (
BearerTransport, BearerTransport,
CookieTransport, CookieTransport,

6
fastapi_users/authentication/strategy/__init__.py
View File

@@ -3,7 +3,11 @@ from fastapi_users.authentication.strategy.base import (
StrategyDestroyNotSupportedError, StrategyDestroyNotSupportedError,
) )
from fastapi_users.authentication.strategy.jwt import JWTStrategy from fastapi_users.authentication.strategy.jwt import JWTStrategy
from fastapi_users.authentication.strategy.redis import RedisStrategy
try:
from fastapi_users.authentication.strategy.redis import RedisStrategy
except ImportError: # pragma: no cover
pass
__all__ = [ __all__ = [
"JWTStrategy", "JWTStrategy",