Introduce Python import sorting to our sanity test suite (#26768)

* Add isort_code.sh to sanity tests

* Run tools/distrib/isort_code.sh

* Fine tune the import order for relative imports

* Make pylint and project generation happy

* Fix a few corner cases

* Use --check instead of --diff

* The import order impacts test result somehow

* Make isort print diff and check output at the same time

* Let tools/run_tests/python_utils be firstparty library

* Run isort against latest HEAD
reviewable/pr26643/r8
Lidi Zheng 3 years ago committed by GitHub
parent 467c5ac73e
commit 2231c2ba77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .pylintrc
  2. 2
      .pylintrc-examples
  3. 2
      .pylintrc-tests
  4. 2
      examples/python/async_streaming/client.py
  5. 6
      examples/python/async_streaming/server.py
  6. 3
      examples/python/auth/async_customized_auth_client.py
  7. 3
      examples/python/auth/async_customized_auth_server.py
  8. 2
      examples/python/auth/customized_auth_client.py
  9. 4
      examples/python/auth/customized_auth_server.py
  10. 5
      examples/python/auth/test/_auth_example_test.py
  11. 2
      examples/python/cancellation/server.py
  12. 1
      examples/python/compression/client.py
  13. 3
      examples/python/compression/server.py
  14. 6
      examples/python/data_transmission/alts_client.py
  15. 3
      examples/python/data_transmission/client.py
  16. 5
      examples/python/data_transmission/server.py
  17. 2
      examples/python/debug/asyncio_debug_server.py
  18. 4
      examples/python/debug/asyncio_get_stats.py
  19. 3
      examples/python/debug/asyncio_send_message.py
  20. 2
      examples/python/debug/debug_server.py
  21. 4
      examples/python/debug/get_stats.py
  22. 3
      examples/python/debug/send_message.py
  23. 6
      examples/python/debug/test/_debug_example_test.py
  24. 3
      examples/python/errors/client.py
  25. 7
      examples/python/errors/server.py
  26. 2
      examples/python/errors/test/_error_handling_example_test.py
  27. 4
      examples/python/helloworld/async_greeter_client.py
  28. 1
      examples/python/helloworld/async_greeter_client_with_options.py
  29. 4
      examples/python/helloworld/async_greeter_server.py
  30. 4
      examples/python/helloworld/async_greeter_server_with_graceful_shutdown.py
  31. 1
      examples/python/helloworld/async_greeter_server_with_reflection.py
  32. 2
      examples/python/helloworld/greeter_client.py
  33. 2
      examples/python/helloworld/greeter_client_with_options.py
  34. 1
      examples/python/helloworld/greeter_server.py
  35. 1
      examples/python/helloworld/greeter_server_with_reflection.py
  36. 4
      examples/python/interceptors/default_value/greeter_client.py
  37. 4
      examples/python/interceptors/headers/greeter_client.py
  38. 4
      examples/python/interceptors/headers/greeter_server.py
  39. 2
      examples/python/interceptors/headers/header_manipulator_client_interceptor.py
  40. 2
      examples/python/metadata/metadata_client.py
  41. 2
      examples/python/metadata/metadata_server.py
  42. 3
      examples/python/multiplex/multiplex_client.py
  43. 5
      examples/python/multiplex/multiplex_server.py
  44. 1
      examples/python/multiprocessing/client.py
  45. 3
      examples/python/multiprocessing/server.py
  46. 1
      examples/python/no_codegen/greeter_client.py
  47. 5
      examples/python/route_guide/asyncio_route_guide_client.py
  48. 5
      examples/python/route_guide/asyncio_route_guide_server.py
  49. 3
      examples/python/route_guide/route_guide_client.py
  50. 5
      examples/python/route_guide/route_guide_server.py
  51. 2
      examples/python/wait_for_ready/asyncio_wait_for_ready_example.py
  52. 4
      examples/python/wait_for_ready/test/_wait_for_ready_example_test.py
  53. 2
      examples/python/wait_for_ready/wait_for_ready_example.py
  54. 4
      examples/python/xds/client.py
  55. 10
      examples/python/xds/server.py
  56. 16
      setup.py
  57. 1
      src/python/grpcio/commands.py
  58. 10
      src/python/grpcio/grpc/__init__.py
  59. 4
      src/python/grpcio/grpc/_channel.py
  60. 2
      src/python/grpcio/grpc/_common.py
  61. 1
      src/python/grpcio/grpc/_plugin_wrapping.py
  62. 5
      src/python/grpcio/grpc/_server.py
  63. 2
      src/python/grpcio/grpc/_simple_stubs.py
  64. 5
      src/python/grpcio/grpc/_utilities.py
  65. 48
      src/python/grpcio/grpc/aio/__init__.py
  66. 8
      src/python/grpcio/grpc/aio/_base_call.py
  67. 5
      src/python/grpcio/grpc/aio/_base_channel.py
  68. 5
      src/python/grpcio/grpc/aio/_base_server.py
  69. 12
      src/python/grpcio/grpc/aio/_call.py
  70. 35
      src/python/grpcio/grpc/aio/_channel.py
  71. 27
      src/python/grpcio/grpc/aio/_interceptor.py
  72. 5
      src/python/grpcio/grpc/aio/_metadata.py
  73. 5
      src/python/grpcio/grpc/aio/_server.py
  74. 5
      src/python/grpcio/grpc/aio/_typing.py
  75. 3
      src/python/grpcio/grpc/beta/implementations.py
  76. 3
      src/python/grpcio/grpc/beta/interfaces.py
  77. 5
      src/python/grpcio/grpc/experimental/__init__.py
  78. 3
      src/python/grpcio/grpc/framework/foundation/logging_pool.py
  79. 3
      src/python/grpcio/grpc/framework/interfaces/base/base.py
  80. 4
      src/python/grpcio/grpc/framework/interfaces/face/face.py
  81. 3
      src/python/grpcio/support.py
  82. 2
      src/python/grpcio_admin/grpc_admin/__init__.py
  83. 4
      src/python/grpcio_channelz/grpc_channelz/v1/_async.py
  84. 4
      src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py
  85. 4
      src/python/grpcio_channelz/grpc_channelz/v1/channelz.py
  86. 1
      src/python/grpcio_channelz/setup.py
  87. 8
      src/python/grpcio_csds/grpc_csds/__init__.py
  88. 2
      src/python/grpcio_health_checking/grpc_health/v1/_async.py
  89. 4
      src/python/grpcio_health_checking/grpc_health/v1/health.py
  90. 1
      src/python/grpcio_health_checking/setup.py
  91. 1
      src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py
  92. 3
      src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py
  93. 6
      src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
  94. 1
      src/python/grpcio_reflection/setup.py
  95. 6
      src/python/grpcio_status/grpc_status/_async.py
  96. 5
      src/python/grpcio_status/grpc_status/rpc_status.py
  97. 1
      src/python/grpcio_status/setup.py
  98. 3
      src/python/grpcio_testing/grpc_testing/__init__.py
  99. 1
      src/python/grpcio_testing/grpc_testing/_server/_service.py
  100. 1
      src/python/grpcio_testing/setup.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -95,5 +95,7 @@ disable=
no-else-return,
# NOTE(lidiz): Python 3 make object inheritance default, but not PY2
useless-object-inheritance,
# NOTE(lidiz): the import order will be enforced by isort instead
wrong-import-order,
# NOTE(sergiitk): yapf compatibility, ref #25071
bad-continuation,

@ -98,5 +98,7 @@ disable=
no-else-return,
# NOTE(lidiz): Python 3 make object inheritance default, but not PY2
useless-object-inheritance,
# NOTE(lidiz): the import order will be enforced by isort instead
wrong-import-order,
# NOTE(sergiitk): yapf compatibility, ref #25071
bad-continuation,

@ -124,5 +124,7 @@ disable=
no-else-return,
# NOTE(lidiz): Python 3 make object inheritance default, but not PY2
useless-object-inheritance,
# NOTE(lidiz): the import order will be enforced by isort instead
wrong-import-order,
# NOTE(sergiitk): yapf compatibility, ref #25071
bad-continuation,

@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from concurrent.futures import ThreadPoolExecutor
import logging
import threading
from typing import Iterator
from concurrent.futures import ThreadPoolExecutor
import grpc

@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from concurrent.futures import ThreadPoolExecutor
import logging
import threading
import time
from concurrent.futures import ThreadPoolExecutor
from typing import Iterable
import threading
import grpc
from google.protobuf.json_format import MessageToJson
import grpc
import phone_pb2
import phone_pb2_grpc

@ -17,9 +17,8 @@ import argparse
import asyncio
import logging
import grpc
import _credentials
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
"helloworld.proto")

@ -18,9 +18,8 @@ import asyncio
import logging
from typing import Awaitable, Callable, Tuple
import grpc
import _credentials
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
"helloworld.proto")

@ -17,8 +17,8 @@ import argparse
import contextlib
import logging
import grpc
import _credentials
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
"helloworld.proto")

@ -14,12 +14,12 @@
"""Server of the Python example of customizing authentication mechanism."""
import argparse
from concurrent import futures
import contextlib
import logging
from concurrent import futures
import grpc
import _credentials
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
"helloworld.proto")

@ -17,11 +17,12 @@ import asyncio
import unittest
import grpc
from examples.python.auth import _credentials
from examples.python.auth import customized_auth_client
from examples.python.auth import customized_auth_server
from examples.python.auth import async_customized_auth_client
from examples.python.auth import async_customized_auth_server
from examples.python.auth import customized_auth_client
from examples.python.auth import customized_auth_server
_SERVER_ADDR_TEMPLATE = 'localhost:%d'

@ -17,8 +17,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from concurrent import futures
import argparse
from concurrent import futures
import logging
import threading

@ -19,6 +19,7 @@ from __future__ import print_function
import argparse
import logging
import grpc
from examples.protos import helloworld_pb2

@ -17,10 +17,11 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from concurrent import futures
import argparse
from concurrent import futures
import logging
import threading
import grpc
from examples.protos import helloworld_pb2

@ -17,9 +17,11 @@ The example would only successfully run in GCP environment."""
import grpc
from client import bidirectional_streaming_method
from client import client_streaming_method
from client import server_streaming_method
from client import simple_method
import demo_pb2_grpc
from client import (bidirectional_streaming_method, client_streaming_method,
server_streaming_method, simple_method)
SERVER_ADDRESS = "localhost:23333"

@ -14,10 +14,11 @@
"""The example of four ways of data transmission using gRPC in Python."""
import time
import grpc
import demo_pb2_grpc
import demo_pb2
import demo_pb2_grpc
__all__ = [
'simple_method', 'client_streaming_method', 'server_streaming_method',

@ -13,12 +13,13 @@
# limitations under the License.
"""The example of four ways of data transmission using gRPC in Python."""
from threading import Thread
from concurrent import futures
from threading import Thread
import grpc
import demo_pb2_grpc
import demo_pb2
import demo_pb2_grpc
__all__ = 'DemoServer'
SERVER_ADDRESS = 'localhost:23333'

@ -13,8 +13,8 @@
# limitations under the License.
"""The Python AsyncIO example of utilizing Channelz feature."""
import asyncio
import argparse
import asyncio
import logging
import random

@ -13,11 +13,11 @@
# limitations under the License.
"""Poll statistics from the server."""
import argparse
import asyncio
import logging
import argparse
import grpc
import grpc
from grpc_channelz.v1 import channelz_pb2
from grpc_channelz.v1 import channelz_pb2_grpc

@ -13,9 +13,10 @@
# limitations under the License.
"""Send multiple greeting messages to the backend."""
import argparse
import asyncio
import logging
import argparse
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(

@ -18,8 +18,8 @@ from __future__ import division
from __future__ import print_function
import argparse
import logging
from concurrent import futures
import logging
import random
import grpc

@ -17,10 +17,10 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import argparse
import grpc
import logging
import grpc
from grpc_channelz.v1 import channelz_pb2
from grpc_channelz.v1 import channelz_pb2_grpc

@ -17,8 +17,9 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import argparse
import logging
import grpc
helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(

@ -17,12 +17,12 @@ import asyncio
import logging
import unittest
from examples.python.debug import debug_server
from examples.python.debug import asyncio_debug_server
from examples.python.debug import send_message
from examples.python.debug import asyncio_get_stats
from examples.python.debug import asyncio_send_message
from examples.python.debug import debug_server
from examples.python.debug import get_stats
from examples.python.debug import asyncio_get_stats
from examples.python.debug import send_message
_LOGGER = logging.getLogger(__name__)
_LOGGER.setLevel(logging.INFO)

@ -14,11 +14,12 @@
"""This example handles rich error status in client-side."""
from __future__ import print_function
import logging
from google.rpc import error_details_pb2
import grpc
from grpc_status import rpc_status
from google.rpc import error_details_pb2
from examples.protos import helloworld_pb2
from examples.protos import helloworld_pb2_grpc

@ -17,12 +17,13 @@ from concurrent import futures
import logging
import threading
from google.protobuf import any_pb2
from google.rpc import code_pb2
from google.rpc import error_details_pb2
from google.rpc import status_pb2
import grpc
from grpc_status import rpc_status
from google.protobuf import any_pb2
from google.rpc import code_pb2, status_pb2, error_details_pb2
from examples.protos import helloworld_pb2
from examples.protos import helloworld_pb2_grpc

@ -21,8 +21,8 @@ try:
except ImportError:
pass
import unittest
import logging
import unittest
import grpc

@ -13,10 +13,10 @@
# limitations under the License.
"""The Python AsyncIO implementation of the GRPC helloworld.Greeter client."""
import logging
import asyncio
import grpc
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -17,7 +17,6 @@ import asyncio
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -13,10 +13,10 @@
# limitations under the License.
"""The Python AsyncIO implementation of the GRPC helloworld.Greeter server."""
import logging
import asyncio
import grpc
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -13,10 +13,10 @@
# limitations under the License.
"""The graceful shutdown example for the asyncio Greeter server."""
import logging
import asyncio
import grpc
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -18,7 +18,6 @@ import logging
import grpc
from grpc_reflection.v1alpha import reflection
import helloworld_pb2
import helloworld_pb2_grpc

@ -14,10 +14,10 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -14,10 +14,10 @@
"""gRPC Python helloworld.Greeter client with channel options and call timeout parameters."""
from __future__ import print_function
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -17,7 +17,6 @@ from concurrent import futures
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -18,7 +18,6 @@ import logging
import grpc
from grpc_reflection.v1alpha import reflection
import helloworld_pb2
import helloworld_pb2_grpc

@ -14,13 +14,13 @@
"""The Python implementation of the gRPC helloworld.Greeter client."""
from __future__ import print_function
import logging
import default_value_client_interceptor
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
import default_value_client_interceptor
def run():

@ -14,13 +14,13 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
import logging
import grpc
import header_manipulator_client_interceptor
import helloworld_pb2
import helloworld_pb2_grpc
import header_manipulator_client_interceptor
def run():

@ -17,10 +17,10 @@ from concurrent import futures
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
from request_header_validator_interceptor import RequestHeaderValidatorInterceptor
from request_header_validator_interceptor import \
RequestHeaderValidatorInterceptor
class Greeter(helloworld_pb2_grpc.GreeterServicer):

@ -15,8 +15,8 @@
import collections
import grpc
import generic_client_interceptor
import grpc
class _ClientCallDetails(

@ -14,10 +14,10 @@
"""Example gRPC client that gets/sets metadata (HTTP2 headers)"""
from __future__ import print_function
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -14,11 +14,11 @@
"""Example gRPC server that gets/sets metadata (HTTP2 headers)"""
from __future__ import print_function
from concurrent import futures
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc

@ -15,12 +15,11 @@
from __future__ import print_function
import logging
import random
import time
import logging
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
import route_guide_pb2

@ -14,12 +14,11 @@
"""A gRPC server servicing both Greeter and RouteGuide RPCs."""
from concurrent import futures
import time
import math
import logging
import math
import time
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
import route_guide_pb2

@ -25,7 +25,6 @@ import operator
import sys
import grpc
import prime_pb2
import prime_pb2_grpc

@ -23,12 +23,11 @@ import datetime
import logging
import math
import multiprocessing
import time
import socket
import sys
import time
import grpc
import prime_pb2
import prime_pb2_grpc

@ -20,6 +20,7 @@ Several APIs used in this example are in an experimental state.
"""
from __future__ import print_function
import logging
import grpc

@ -14,12 +14,11 @@
"""The Python AsyncIO implementation of the gRPC route guide client."""
import asyncio
import random
import logging
from typing import List, Iterable
import random
from typing import Iterable, List
import grpc
import route_guide_pb2
import route_guide_pb2_grpc
import route_guide_resources

@ -14,13 +14,12 @@
"""The Python AsyncIO implementation of the gRPC route guide server."""
import asyncio
import time
import math
import logging
import math
import time
from typing import AsyncIterable, Iterable
import grpc
import route_guide_pb2
import route_guide_pb2_grpc
import route_guide_resources

@ -15,11 +15,10 @@
from __future__ import print_function
import random
import logging
import random
import grpc
import route_guide_pb2
import route_guide_pb2_grpc
import route_guide_resources

@ -14,12 +14,11 @@
"""The Python implementation of the gRPC route guide server."""
from concurrent import futures
import time
import math
import logging
import math
import time
import grpc
import route_guide_pb2
import route_guide_pb2_grpc
import route_guide_resources

@ -14,8 +14,8 @@
"""The Python example of utilizing wait-for-ready flag."""
import asyncio
import logging
from contextlib import contextmanager
import logging
import socket
from typing import Iterable

@ -14,11 +14,11 @@
"""Tests of the wait-for-ready example."""
import asyncio
import unittest
import logging
import unittest
from examples.python.wait_for_ready import wait_for_ready_example
from examples.python.wait_for_ready import asyncio_wait_for_ready_example
from examples.python.wait_for_ready import wait_for_ready_example
class WaitForReadyExampleTest(unittest.TestCase):

@ -13,9 +13,9 @@
# limitations under the License.
"""The Python example of utilizing wait-for-ready flag."""
import logging
from concurrent import futures
from contextlib import contextmanager
import logging
import socket
import threading

@ -14,12 +14,12 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
import logging
import argparse
import logging
import grpc
import grpc.experimental
import helloworld_pb2
import helloworld_pb2_grpc

@ -13,20 +13,18 @@
# limitations under the License.
"""The Python implementation of the GRPC helloworld.Greeter server."""
from concurrent import futures
import argparse
from concurrent import futures
import logging
import socket
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
from grpc_reflection.v1alpha import reflection
from grpc_health.v1 import health
from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
from grpc_reflection.v1alpha import reflection
import helloworld_pb2
import helloworld_pb2_grpc
_DESCRIPTION = "A general purpose phony server."

@ -15,11 +15,12 @@
# setuptools need to be imported before distutils. Otherwise it might lead to
# undesirable behaviors or errors.
import setuptools
import setuptools # isort:skip
# Monkey Patch the unix compiler to accept ASM
# files used by boring SSL.
from distutils.unixccompiler import UnixCCompiler
UnixCCompiler.src_extensions.append('.S')
del UnixCCompiler
@ -28,20 +29,18 @@ from distutils import extension as _extension
from distutils import util
import os
import os.path
import pkg_resources
import platform
import re
import shlex
import shutil
import sys
import sysconfig
from setuptools.command import egg_info
import subprocess
from subprocess import PIPE
import sys
import sysconfig
import _metadata
import pkg_resources
from setuptools.command import egg_info
# Redirect the manifest template from MANIFEST.in to PYTHON-MANIFEST.in.
egg_info.manifest_maker.template = 'PYTHON-MANIFEST.in'
@ -86,8 +85,9 @@ sys.path.insert(0, os.path.abspath(PYTHON_STEM))
# Break import-style to ensure we can actually find our in-repo dependencies.
import _parallel_compile_patch
import _spawn_patch
import commands
import grpc_core_dependencies
import commands
import grpc_version
_parallel_compile_patch.monkeypatch_compile_maybe()

@ -33,7 +33,6 @@ from setuptools.command import build_py
from setuptools.command import easy_install
from setuptools.command import install
from setuptools.command import test
import support
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))

@ -18,14 +18,18 @@ import contextlib
import enum
import logging
import sys
import six
from grpc._cython import cygrpc as _cygrpc
from grpc import _compression
from grpc._cython import cygrpc as _cygrpc
from grpc._runtime_protos import protos
from grpc._runtime_protos import protos_and_services
from grpc._runtime_protos import services
import six
logging.getLogger(__name__).addHandler(logging.NullHandler())
try:
# pylint: disable=ungrouped-imports
from grpc._grpcio_metadata import __version__
except ImportError:
__version__ = "dev0"
@ -2092,8 +2096,6 @@ class Compression(enum.IntEnum):
Gzip = _compression.Gzip
from grpc._runtime_protos import protos, services, protos_and_services # pylint: disable=wrong-import-position
################################### __all__ #################################
__all__ = (

@ -22,11 +22,11 @@ import threading
import time
import grpc
import grpc.experimental
from grpc import _compression
from grpc import _common
from grpc import _compression
from grpc import _grpcio_metadata
from grpc._cython import cygrpc
import grpc.experimental
_LOGGER = logging.getLogger(__name__)

@ -15,10 +15,10 @@
import logging
import time
import six
import grpc
from grpc._cython import cygrpc
import six
_LOGGER = logging.getLogger(__name__)

@ -72,6 +72,7 @@ class _Plugin(object):
try:
import contextvars # pylint: disable=wrong-import-position
# The plugin may be invoked on a thread created by Core, which will not
# have the context propagated. This context is stored and installed in
# the thread invoking the plugin.

@ -14,19 +14,18 @@
"""Service-side implementation of gRPC Python."""
import collections
from concurrent import futures
import enum
import logging
import threading
import time
from concurrent import futures
import six
import grpc
from grpc import _common
from grpc import _compression
from grpc import _interceptor
from grpc._cython import cygrpc
import six
_LOGGER = logging.getLogger(__name__)

@ -15,8 +15,8 @@
import collections
import datetime
import os
import logging
import os
import threading
from typing import (Any, AnyStr, Callable, Dict, Iterator, Optional, Sequence,
Tuple, TypeVar, Union)

@ -14,14 +14,13 @@
"""Internal utilities for gRPC Python."""
import collections
import logging
import threading
import time
import logging
import six
import grpc
from grpc import _common
import six
_LOGGER = logging.getLogger(__name__)

@ -20,27 +20,41 @@ created. AsyncIO doesn't provide thread safety for most of its APIs.
from typing import Any, Optional, Sequence, Tuple
import grpc
from grpc._cython.cygrpc import (init_grpc_aio, shutdown_grpc_aio, EOF,
AbortError, BaseError, InternalError,
UsageError)
from grpc._cython.cygrpc import AbortError
from grpc._cython.cygrpc import BaseError
from grpc._cython.cygrpc import EOF
from grpc._cython.cygrpc import InternalError
from grpc._cython.cygrpc import UsageError
from grpc._cython.cygrpc import init_grpc_aio
from grpc._cython.cygrpc import shutdown_grpc_aio
from ._base_call import (Call, RpcContext, StreamStreamCall, StreamUnaryCall,
UnaryStreamCall, UnaryUnaryCall)
from ._base_channel import (Channel, StreamStreamMultiCallable,
StreamUnaryMultiCallable, UnaryStreamMultiCallable,
UnaryUnaryMultiCallable)
from ._base_call import Call
from ._base_call import RpcContext
from ._base_call import StreamStreamCall
from ._base_call import StreamUnaryCall
from ._base_call import UnaryStreamCall
from ._base_call import UnaryUnaryCall
from ._base_channel import Channel
from ._base_channel import StreamStreamMultiCallable
from ._base_channel import StreamUnaryMultiCallable
from ._base_channel import UnaryStreamMultiCallable
from ._base_channel import UnaryUnaryMultiCallable
from ._base_server import Server
from ._base_server import ServicerContext
from ._call import AioRpcError
from ._interceptor import (ClientCallDetails, ClientInterceptor,
InterceptedUnaryUnaryCall,
UnaryUnaryClientInterceptor,
UnaryStreamClientInterceptor,
StreamUnaryClientInterceptor,
StreamStreamClientInterceptor, ServerInterceptor)
from ._channel import insecure_channel
from ._channel import secure_channel
from ._interceptor import ClientCallDetails
from ._interceptor import ClientInterceptor
from ._interceptor import InterceptedUnaryUnaryCall
from ._interceptor import ServerInterceptor
from ._interceptor import StreamStreamClientInterceptor
from ._interceptor import StreamUnaryClientInterceptor
from ._interceptor import UnaryStreamClientInterceptor
from ._interceptor import UnaryUnaryClientInterceptor
from ._metadata import Metadata
from ._server import server
from ._base_server import Server, ServicerContext
from ._typing import ChannelArgumentType
from ._channel import insecure_channel, secure_channel
from ._metadata import Metadata
################################### __all__ #################################

@ -18,13 +18,17 @@ its information. They also offer methods to manipulate the life-cycle of the
RPC, e.g. cancellation.
"""
from abc import ABCMeta, abstractmethod
from abc import ABCMeta
from abc import abstractmethod
from typing import AsyncIterable, Awaitable, Generic, Optional, Union
import grpc
from ._typing import (DoneCallbackType, EOFType, RequestType, ResponseType)
from ._metadata import Metadata
from ._typing import DoneCallbackType
from ._typing import EOFType
from ._typing import RequestType
from ._typing import ResponseType
__all__ = 'RpcContext', 'Call', 'UnaryUnaryCall', 'UnaryStreamCall'

@ -19,9 +19,10 @@ from typing import Any, Optional
import grpc
from . import _base_call
from ._typing import (DeserializingFunction, RequestIterableType,
SerializingFunction)
from ._metadata import Metadata
from ._typing import DeserializingFunction
from ._typing import RequestIterableType
from ._typing import SerializingFunction
class UnaryUnaryMultiCallable(abc.ABC):

@ -14,12 +14,13 @@
"""Abstract base classes for server-side classes."""
import abc
from typing import Generic, Mapping, Optional, Iterable, Sequence
from typing import Generic, Iterable, Mapping, Optional, Sequence
import grpc
from ._typing import RequestType, ResponseType
from ._metadata import Metadata
from ._typing import RequestType
from ._typing import ResponseType
class Server(abc.ABC):

@ -15,9 +15,9 @@
import asyncio
import enum
from functools import partial
import inspect
import logging
from functools import partial
import traceback
from typing import AsyncIterable, Optional, Tuple
@ -27,9 +27,13 @@ from grpc._cython import cygrpc
from . import _base_call
from ._metadata import Metadata
from ._typing import (DeserializingFunction, DoneCallbackType, MetadatumType,
RequestIterableType, RequestType, ResponseType,
SerializingFunction)
from ._typing import DeserializingFunction
from ._typing import DoneCallbackType
from ._typing import MetadatumType
from ._typing import RequestIterableType
from ._typing import RequestType
from ._typing import ResponseType
from ._typing import SerializingFunction
__all__ = 'AioRpcError', 'Call', 'UnaryUnaryCall', 'UnaryStreamCall'

@ -15,23 +15,34 @@
import asyncio
import sys
from typing import Any, Iterable, Optional, Sequence, List
from typing import Any, Iterable, List, Optional, Sequence
import grpc
from grpc import _common, _compression, _grpcio_metadata
from grpc import _common
from grpc import _compression
from grpc import _grpcio_metadata
from grpc._cython import cygrpc
from . import _base_call, _base_channel
from ._call import (StreamStreamCall, StreamUnaryCall, UnaryStreamCall,
UnaryUnaryCall)
from ._interceptor import (
InterceptedUnaryUnaryCall, InterceptedUnaryStreamCall,
InterceptedStreamUnaryCall, InterceptedStreamStreamCall, ClientInterceptor,
UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor,
StreamUnaryClientInterceptor, StreamStreamClientInterceptor)
from . import _base_call
from . import _base_channel
from ._call import StreamStreamCall
from ._call import StreamUnaryCall
from ._call import UnaryStreamCall
from ._call import UnaryUnaryCall
from ._interceptor import ClientInterceptor
from ._interceptor import InterceptedStreamStreamCall
from ._interceptor import InterceptedStreamUnaryCall
from ._interceptor import InterceptedUnaryStreamCall
from ._interceptor import InterceptedUnaryUnaryCall
from ._interceptor import StreamStreamClientInterceptor
from ._interceptor import StreamUnaryClientInterceptor
from ._interceptor import UnaryStreamClientInterceptor
from ._interceptor import UnaryUnaryClientInterceptor
from ._metadata import Metadata
from ._typing import (ChannelArgumentType, DeserializingFunction,
SerializingFunction, RequestIterableType)
from ._typing import ChannelArgumentType
from ._typing import DeserializingFunction
from ._typing import RequestIterableType
from ._typing import SerializingFunction
from ._utils import _timeout_to_deadline
_USER_AGENT = 'grpc-python-asyncio/{}'.format(_grpcio_metadata.__version__)

@ -12,24 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Interceptors implementation of gRPC Asyncio Python."""
from abc import ABCMeta
from abc import abstractmethod
import asyncio
import collections
import functools
from abc import ABCMeta, abstractmethod
from typing import Callable, Optional, Iterator, Sequence, Union, Awaitable, AsyncIterable
from typing import (AsyncIterable, Awaitable, Callable, Iterator, Optional,
Sequence, Union)
import grpc
from grpc._cython import cygrpc
from . import _base_call
from ._call import UnaryUnaryCall, UnaryStreamCall, StreamUnaryCall, StreamStreamCall, AioRpcError
from ._call import _RPC_ALREADY_FINISHED_DETAILS, _RPC_HALF_CLOSED_DETAILS
from ._call import AioRpcError
from ._call import StreamStreamCall
from ._call import StreamUnaryCall
from ._call import UnaryStreamCall
from ._call import UnaryUnaryCall
from ._call import _API_STYLE_ERROR
from ._utils import _timeout_to_deadline
from ._typing import (RequestType, SerializingFunction, DeserializingFunction,
ResponseType, DoneCallbackType, RequestIterableType,
ResponseIterableType)
from ._call import _RPC_ALREADY_FINISHED_DETAILS
from ._call import _RPC_HALF_CLOSED_DETAILS
from ._metadata import Metadata
from ._typing import DeserializingFunction
from ._typing import DoneCallbackType
from ._typing import RequestIterableType
from ._typing import RequestType
from ._typing import ResponseIterableType
from ._typing import ResponseType
from ._typing import SerializingFunction
from ._utils import _timeout_to_deadline
_LOCAL_CANCELLATION_DETAILS = 'Locally cancelled by application!'

@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Implementation of the metadata abstraction for gRPC Asyncio Python."""
from typing import List, Tuple, Iterator, Any, Union
from collections import abc, OrderedDict
from collections import OrderedDict
from collections import abc
from typing import Any, Iterator, List, Tuple, Union
MetadataKey = str
MetadataValue = Union[str, bytes]

@ -17,12 +17,13 @@ from concurrent.futures import Executor
from typing import Any, Optional, Sequence
import grpc
from grpc import _common, _compression
from grpc import _common
from grpc import _compression
from grpc._cython import cygrpc
from . import _base_server
from ._typing import ChannelArgumentType
from ._interceptor import ServerInterceptor
from ._typing import ChannelArgumentType
def _augment_channel_arguments(base_options: ChannelArgumentType,

@ -17,7 +17,10 @@ from typing import (Any, AsyncIterable, Callable, Iterable, Sequence, Tuple,
TypeVar, Union)
from grpc._cython.cygrpc import EOF
from ._metadata import Metadata, MetadataKey, MetadataValue
from ._metadata import Metadata
from ._metadata import MetadataKey
from ._metadata import MetadataValue
RequestType = TypeVar('RequestType')
ResponseType = TypeVar('ResponseType')

@ -25,7 +25,8 @@ from grpc.beta import _metadata
from grpc.beta import _server_adaptations
from grpc.beta import interfaces # pylint: disable=unused-import
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from grpc.framework.interfaces.face import \
face # pylint: disable=unused-import
# pylint: disable=too-many-arguments

@ -15,9 +15,8 @@
import abc
import six
import grpc
import six
ChannelConnectivity = grpc.ChannelConnectivity
# FATAL_FAILURE was a Beta-API name for SHUTDOWN

@ -121,5 +121,8 @@ __all__ = (
)
if sys.version_info > (3, 6):
from grpc._simple_stubs import unary_unary, unary_stream, stream_unary, stream_stream
from grpc._simple_stubs import stream_stream
from grpc._simple_stubs import stream_unary
from grpc._simple_stubs import unary_stream
from grpc._simple_stubs import unary_unary
__all__ = __all__ + (unary_unary, unary_stream, stream_unary, stream_stream)

@ -13,9 +13,8 @@
# limitations under the License.
"""A thread pool that logs exceptions raised by tasks executed within it."""
import logging
from concurrent import futures
import logging
_LOGGER = logging.getLogger(__name__)

@ -28,9 +28,6 @@ import threading # pylint: disable=unused-import
import six
# abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
# pylint: disable=too-many-arguments

@ -17,15 +17,13 @@ import abc
import collections
import enum
import six
# cardinality, style, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.common import style # pylint: disable=unused-import
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
from grpc.framework.foundation import future # pylint: disable=unused-import
from grpc.framework.foundation import stream # pylint: disable=unused-import
import six
# pylint: disable=too-many-arguments

@ -12,14 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from distutils import errors
import os
import os.path
import shutil
import sys
import tempfile
from distutils import errors
import commands
C_PYTHON_DEV = """

@ -13,8 +13,8 @@
# limitations under the License.
"""gRPC Python's Admin interface."""
import grpc_csds
from grpc_channelz.v1 import channelz
import grpc_csds
def add_admin_servicers(server):

@ -14,10 +14,10 @@
"""AsyncIO version of Channelz servicer."""
from grpc.experimental import aio
from grpc_channelz.v1._servicer import \
ChannelzServicer as _SyncChannelzServicer
import grpc_channelz.v1.channelz_pb2 as _channelz_pb2
import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc
from grpc_channelz.v1._servicer import ChannelzServicer as _SyncChannelzServicer
class ChannelzServicer(_channelz_pb2_grpc.ChannelzServicer):

@ -13,14 +13,12 @@
# limitations under the License.
"""Channelz debug service implementation in gRPC Python."""
from google.protobuf import json_format
import grpc
from grpc._cython import cygrpc
import grpc_channelz.v1.channelz_pb2 as _channelz_pb2
import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc
from google.protobuf import json_format
class ChannelzServicer(_channelz_pb2_grpc.ChannelzServicer):
"""Servicer handling RPCs for service statuses."""

@ -14,10 +14,10 @@
"""Channelz debug service implementation in gRPC Python."""
import sys
import grpc
import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc
import grpc
from grpc_channelz.v1._servicer import ChannelzServicer
import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc
_add_channelz_servicer_doc = """Add Channelz servicer to a server.

@ -68,6 +68,7 @@ INSTALL_REQUIRES = (
try:
import channelz_commands as _channelz_commands
# we are in the build environment, otherwise the above import fails
SETUP_REQUIRES = ('grpcio-tools=={version}'.format(
version=grpc_version.VERSION),)

@ -13,13 +13,15 @@
# limitations under the License.
"""Channelz debug service implementation in gRPC Python."""
from google.protobuf import json_format
from grpc._cython import cygrpc
from google.protobuf import json_format
try:
from envoy.service.status.v3 import csds_pb2, csds_pb2_grpc
from envoy.service.status.v3 import csds_pb2
from envoy.service.status.v3 import csds_pb2_grpc
except ImportError:
from src.proto.grpc.testing.xds.v3 import csds_pb2, csds_pb2_grpc
from src.proto.grpc.testing.xds.v3 import csds_pb2
from src.proto.grpc.testing.xds.v3 import csds_pb2_grpc
class ClientStatusDiscoveryServiceServicer(

@ -16,8 +16,8 @@
import asyncio
import collections
from typing import MutableMapping
import grpc
import grpc
from grpc_health.v1 import health_pb2 as _health_pb2
from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc

@ -14,10 +14,10 @@
"""Reference implementation for health checking in gRPC Python."""
import collections
import threading
import sys
import grpc
import threading
import grpc
from grpc_health.v1 import health_pb2 as _health_pb2
from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc

@ -67,6 +67,7 @@ INSTALL_REQUIRES = (
try:
import health_commands as _health_commands
# we are in the build environment, otherwise the above import fails
SETUP_REQUIRES = ('grpcio-tools=={version}'.format(
version=grpc_version.VERSION),)

@ -16,7 +16,6 @@
from typing import AsyncIterable
import grpc
from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2
from grpc_reflection.v1alpha._base import BaseReflectionServicer

@ -13,10 +13,9 @@
# limitations under the License.
"""Base implementation of reflection servicer."""
import grpc
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
import grpc
from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2
from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc

@ -14,11 +14,10 @@
"""Reference implementation for reflection in gRPC Python."""
import sys
import grpc
import grpc
from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2
from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc
from grpc_reflection.v1alpha._base import BaseReflectionServicer
SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[
@ -64,9 +63,10 @@ Args:
if sys.version_info[0] >= 3 and sys.version_info[1] >= 6:
# Exposes AsyncReflectionServicer as public API.
from . import _async as aio
from grpc.experimental import aio as grpc_aio # pylint: disable=ungrouped-imports
from . import _async as aio
def enable_server_reflection(service_names, server, pool=None):
if isinstance(server, grpc_aio.Server):
_reflection_pb2_grpc.add_ServerReflectionServicer_to_server(

@ -68,6 +68,7 @@ INSTALL_REQUIRES = (
try:
import reflection_commands as _reflection_commands
# we are in the build environment, otherwise the above import fails
SETUP_REQUIRES = ('grpcio-tools=={version}'.format(
version=grpc_version.VERSION),)

@ -13,11 +13,11 @@
# limitations under the License.
"""Reference implementation for status mapping in gRPC Python."""
from grpc.experimental import aio
from google.rpc import status_pb2
from grpc.experimental import aio
from ._common import code_to_grpc_status_code, GRPC_DETAILS_METADATA_KEY
from ._common import GRPC_DETAILS_METADATA_KEY
from ._common import code_to_grpc_status_code
async def from_call(call: aio.Call):

@ -16,10 +16,11 @@
import collections
import sys
from google.rpc import status_pb2
import grpc
from google.rpc import status_pb2
from ._common import code_to_grpc_status_code, GRPC_DETAILS_METADATA_KEY
from ._common import GRPC_DETAILS_METADATA_KEY
from ._common import code_to_grpc_status_code
class _Status(

@ -68,6 +68,7 @@ INSTALL_REQUIRES = (
try:
import status_commands as _status_commands
# we are in the build environment, otherwise the above import fails
COMMAND_CLASS = {
# Run preprocess from the repository *before* doing any packaging!

@ -14,11 +14,10 @@
"""Objects for use in testing gRPC Python-using application code."""
import abc
import six
from google.protobuf import descriptor
import grpc
import six
class UnaryUnaryChannelRpc(six.with_metaclass(abc.ABCMeta)):

@ -13,6 +13,7 @@
# limitations under the License.
import copy
import grpc

@ -55,6 +55,7 @@ INSTALL_REQUIRES = (
try:
import testing_commands as _testing_commands
# we are in the build environment, otherwise the above import fails
COMMAND_CLASS = {
# Run preprocess from the repository *before* doing any packaging!

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save