Skip to content

Commit 902904b

Browse files
committed
revert
1 parent 713b557 commit 902904b

5 files changed

Lines changed: 15 additions & 42 deletions

File tree

packages/google-api-core/google/api_core/exceptions.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
on :mod:`google.api_core`, including both HTTP and gRPC clients.
1919
"""
2020

21-
from __future__ import absolute_import, unicode_literals
21+
from __future__ import absolute_import
22+
from __future__ import unicode_literals
2223

2324
import http.client
25+
from typing import Optional, Dict
2426
import warnings
25-
from typing import Dict, Optional
2627

2728
from google.rpc import error_details_pb2
2829

@@ -656,20 +657,9 @@ def from_grpc_error(rpc_exc):
656657
grpc is not None and isinstance(rpc_exc, grpc.Call)
657658
) or _is_informative_grpc_error(rpc_exc):
658659
details, err_info = _parse_grpc_error_details(rpc_exc)
659-
message = rpc_exc.details()
660-
if (
661-
grpc is not None
662-
and rpc_exc.code() == grpc.StatusCode.UNIMPLEMENTED
663-
and "Received http2 header with status: 404" in message
664-
):
665-
message = (
666-
f"{message}. This usually indicates that the 'api_endpoint' "
667-
"configuration in ClientOptions is incorrect, contains a typo, "
668-
"or is an invalid regional endpoint for this service."
669-
)
670660
return from_grpc_status(
671661
rpc_exc.code(),
672-
message,
662+
rpc_exc.details(),
673663
errors=(rpc_exc,),
674664
details=details,
675665
response=rpc_exc,

packages/google-api-core/google/api_core/gapic_v1/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from google.api_core.gapic_v1 import (
16-
client_info,
17-
config,
18-
config_async,
19-
method,
20-
method_async,
21-
routing_header,
22-
)
15+
from google.api_core.gapic_v1 import client_info
16+
from google.api_core.gapic_v1 import config
17+
from google.api_core.gapic_v1 import config_async
18+
from google.api_core.gapic_v1 import method
19+
from google.api_core.gapic_v1 import method_async
20+
from google.api_core.gapic_v1 import routing_header
2321

2422
__all__ = [
2523
"client_info",

packages/google-api-core/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def prerelease_deps(session):
350350
@nox.session(python=DEFAULT_PYTHON_VERSION)
351351
def core_deps_from_source(session):
352352
"""Run the test suite installing dependencies from source."""
353-
default(session, install_deps_from_source=True)
353+
default(session, prerelease=True)
354354

355355

356356
@nox.session(python=DEFAULT_PYTHON_VERSION)

packages/google-api-core/tests/unit/test_bidi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
except ImportError: # pragma: NO COVER
3232
pytest.skip("No GRPC", allow_module_level=True)
3333

34-
from google.api_core import bidi, exceptions
34+
from google.api_core import bidi
35+
from google.api_core import exceptions
3536

3637

3738
class Test_RequestQueueGenerator(object):
@@ -194,7 +195,7 @@ def test_delays_entry_attempts_above_threshold(self):
194195
# (NOTE: not using assert all(...), b/c the coverage check would complain)
195196
for i, entry in enumerate(entries):
196197
if i != 3:
197-
assert entry["reported_wait"] < 0.01
198+
assert entry["reported_wait"] == 0.0
198199

199200
# The delayed entry is expected to have been delayed for a significant
200201
# chunk of the full second, and the actual and reported delay times

packages/google-api-core/tests/unit/test_exceptions.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
except ImportError: # pragma: NO COVER
2626
grpc = rpc_status = None
2727

28+
from google.api_core import exceptions
2829
from google.protobuf import any_pb2, json_format
2930
from google.rpc import error_details_pb2, status_pb2
3031

31-
from google.api_core import exceptions
32-
3332

3433
def test_create_google_cloud_error():
3534
exception = exceptions.GoogleAPICallError("Testing")
@@ -394,18 +393,3 @@ def test_error_details_from_grpc_response_unknown_error():
394393
and exception.domain is None
395394
and exception.metadata is None
396395
)
397-
398-
399-
@pytest.mark.skipif(grpc is None, reason="No grpc")
400-
def test_from_grpc_error_misleading_404():
401-
message = "Received http2 header with status: 404"
402-
error = mock.create_autospec(grpc.Call, instance=True)
403-
error.code.return_value = grpc.StatusCode.UNIMPLEMENTED
404-
error.details.return_value = message
405-
406-
exception = exceptions.from_grpc_error(error)
407-
408-
assert isinstance(exception, exceptions.MethodNotImplemented)
409-
assert exception.grpc_status_code == grpc.StatusCode.UNIMPLEMENTED
410-
assert "Received http2 header with status: 404" in exception.message
411-
assert "api_endpoint" in exception.message

0 commit comments

Comments
 (0)