Skip to content

Commit 2e5baaf

Browse files
1 parent 6791674 commit 2e5baaf

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

googleapiclient/discovery.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@
130130
STACK_QUERY_PARAMETERS = frozenset(["trace", "pp", "userip", "strict"])
131131
STACK_QUERY_PARAMETER_DEFAULT_VALUE = {"type": "string", "location": "query"}
132132

133+
133134
class APICoreVersionError(ValueError):
134135
def __init__(self):
135-
message = "google-api-core >= 2.18.0 is required to use the universe domain feature."
136+
message = (
137+
"google-api-core >= 2.18.0 is required to use the universe domain feature."
138+
)
136139
super().__init__(message)
137140

141+
138142
# Library-specific reserved words beyond Python keywords.
139143
RESERVED_WORDS = frozenset(["body"])
140144

@@ -621,7 +625,7 @@ def build_from_document(
621625
):
622626
credentials = credentials.with_always_use_jwt_access(always_use_jwt_access)
623627
credentials._create_self_signed_jwt(audience_for_self_signed_jwt)
624-
628+
625629
# If credentials are provided, create an authorized http instance;
626630
# otherwise, skip authentication.
627631
if credentials:
@@ -700,7 +704,7 @@ def build_from_document(
700704
credentials = getattr(http, "credentials", None)
701705
universe_domain = getattr(credentials, "universe_domain", None)
702706
if universe_domain != "googleapis.com":
703-
raise APICoreVersionError
707+
raise APICoreVersionError
704708

705709
if model is None:
706710
features = service.get("features", [])

tests/test_discovery.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
STACK_QUERY_PARAMETERS,
7171
V1_DISCOVERY_URI,
7272
V2_DISCOVERY_URI,
73-
ResourceMethodParameters,
7473
APICoreVersionError,
74+
ResourceMethodParameters,
7575
_fix_up_media_path_base_url,
7676
_fix_up_media_upload,
7777
_fix_up_method_description,
@@ -2341,9 +2341,9 @@ def test_get_media(self):
23412341
self.assertEqual(b"standing in for media", response)
23422342

23432343

2344-
23452344
class Universe(unittest.TestCase):
23462345
if HAS_UNIVERSE:
2346+
23472347
def test_validate_credentials_with_no_client_options(self):
23482348
http = build_http()
23492349
discovery = read_datafile("zoo.json")
@@ -2665,7 +2665,7 @@ def test_universe_env_var_configured_with_client_options_universe(self):
26652665
)
26662666

26672667
assert tasks._universe_domain == fake_universe
2668-
2668+
26692669
def test_client_options_universe_with_older_version_of_api_core(self):
26702670
fake_universe = "foo.com"
26712671
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
@@ -2680,7 +2680,6 @@ def test_client_options_universe_with_older_version_of_api_core(self):
26802680
),
26812681
)
26822682

2683-
26842683
def test_credentials_universe_with_older_version_of_api_core(self):
26852684
fake_universe = "foo.com"
26862685
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
@@ -2691,7 +2690,7 @@ def test_credentials_universe_with_older_version_of_api_core(self):
26912690
discovery,
26922691
credentials=credentials,
26932692
)
2694-
2693+
26952694

26962695
if __name__ == "__main__":
26972696
unittest.main()

0 commit comments

Comments
 (0)