Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helpful error messages when importing optional dependencies #125

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion google/auth/transport/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

from __future__ import absolute_import

import grpc
try:
import grpc
except ImportError: # pragma: NO COVER
raise ImportError(
'gRPC is not installed, please install the grpcio package to use the '
'gRPC transport.')
import six


Expand Down
8 changes: 6 additions & 2 deletions google/auth/transport/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

import logging


import requests
try:
import requests
except ImportError: # pragma: NO COVER
raise ImportError(
'The requests library is not installed, please install the requests '
'package to use the requests transport.')
import requests.exceptions

from google.auth import exceptions
Expand Down
7 changes: 6 additions & 1 deletion google/auth/transport/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
except ImportError: # pragma: NO COVER
certifi = None

import urllib3
try:
import urllib3
except ImportError: # pragma: NO COVER
raise ImportError(
'The urllib3 library is not installed, please install the urllib3 '
'package to use the urllib3 transport.')
import urllib3.exceptions

from google.auth import exceptions
Expand Down
7 changes: 6 additions & 1 deletion google/oauth2/oauthlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@

import json

import requests_oauthlib
try:
import requests_oauthlib
except ImportError: # pragma: NO COVER
raise ImportError(
'The requests-oauthlib library is not installed, please install the '
'requests-oauthlib package to use google.oauth2.oauthlib.')

import google.oauth2.credentials

Expand Down