8000 [Python][Part 12] - Introducing Ruff (#40187) · grpc/grpc@deb0be5 · GitHub
[go: up one dir, main page]

Skip to content

Commit deb0be5

Browse files
asheshvidyutcopybara-github
authored andcommitted
[Python][Part 12] - Introducing Ruff (#40187)
### Description ## Part 12 of Introducing Ruff * In this PR - the suppression for `RUF013`, `RUF022`, `RUF023`, `S301` has been removed on the root `ruff.toml` ## Related: * Next: #40188 * Prev: #40186 * b/423755915 Closes #40187 COPYBARA_INTEGRATE_REVIEW=#40187 from asheshvidyut:feature/setup-ruff-part-12 c9120f9 PiperOrigin-RevId: 814551463 8000
1 parent 06cb6fb commit deb0be5

File tree

10 files changed

+90
-94
lines changed

10 files changed

+90
-94
lines changed

ruff.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,9 @@ ignore = [
8080
"RET504", # Unnecessary assignment to {name} before return statement
8181
"RSE102", # Unnecessary parentheses on raised exception
8282
"RUF005", # Consider {expression} instead of concatenation
83-
"RUF013", # PEP 484 prohibits implicit Optional
84-
"RUF022", # __all__ is not sorted
85-
"RUF023", # {}.__slots__ is not sorted
8683
"S101", # Use of assert detected
8784
"S105", # Possible hardcoded password assigned to: "{}"
8885
"S110", # try-except-pass detected, consider logging the exception
89-
"S301", # pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
9086
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
9187
"S603", # subprocess call: check for execution of untrusted input
9288
"SIM102", # Use a single if statement instead of nested if statements

src/python/grpcio/grpc/__init__.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,70 +2252,70 @@ class Compression(enum.IntEnum):
22522252
################################### __all__ #################################
22532253

22542254
__all__ = (
2255-
"FutureTimeoutError",
2256-
"FutureCancelledError",
2257-
"Future",
2258-
"ChannelConnectivity",
2259-
"StatusCode",
2260-
"Status",
2261-
"RpcError",
2262-
"RpcContext",
2263-
"Call",
2264-
"ChannelCredentials",
2265-
"CallCredentials",
22662255
"AuthMetadataContext",
2267-
"AuthMetadataPluginCallback",
22682256
"AuthMetadataPlugin",
2269-
"Compression",
2257+
"AuthMetadataPluginCallback",
2258+
"Call",
2259+
"CallCredentials",
2260+
"Channel",
2261+
"ChannelConnectivity",
2262+
"ChannelCredentials",
22702263
"ClientCallDetails",
2271-
"ServerCertificateConfiguration",
2272-
"ServerCredentials",
2264+
"Compression",
2265+
"Future",
2266+
"FutureCancelledError",
2267+
"FutureTimeoutError",
2268+
"GenericRpcHandler",
2269+
"HandlerCallDetails",
22732270
"LocalConnectionType",
2274-
"UnaryUnaryMultiCallable",
2275-
"UnaryStreamMultiCallable",
2276-
"StreamUnaryMultiCallable",
2277-
"StreamStreamMultiCallable",
2278-
"UnaryUnaryClientInterceptor",
2279-
"UnaryStreamClientInterceptor",
2280-
"StreamUnaryClientInterceptor",
2281-
"StreamStreamClientInterceptor",
2282-
"Channel",
2283-
"ServicerContext",
2271+
"RpcContext",
2272+
"RpcError",
22842273
"RpcMethodHandler",
2285-
"HandlerCallDetails",
2286-
"GenericRpcHandler",
2287-
"ServiceRpcHandler",
22882274
"Server",
2275+
"ServerCertificateConfiguration",
2276+
"ServerCredentials",
22892277
"ServerInterceptor",
2290-
"unary_unary_rpc_method_handler",
2291-
"unary_stream_rpc_method_handler",
2292-
"stream_unary_rpc_method_handler",
2293-
"stream_stream_rpc_method_handler",
2294-
"method_handlers_generic_handler",
2295-
"ssl_channel_credentials",
2296-
"metadata_call_credentials",
2278+
"ServiceRpcHandler",
2279+
"ServicerContext",
2280+
"Status",
2281+
"StatusCode",
2282+
"StreamStreamClientInterceptor",
2283+
"StreamStreamMultiCallable",
2284+
"StreamUnaryClientInterceptor",
2285+
"StreamUnaryMultiCallable",
2286+
"UnaryStreamClientInterceptor",
2287+
"UnaryStreamMultiCallable",
2288+
"UnaryUnaryClientInterceptor",
2289+
"UnaryUnaryMultiCallable",
22972290
"access_token_call_credentials",
2291+
"alts_channel_credentials",
2292+
"alts_server_credentials",
2293+
"channel_ready_future",
22982294
"composite_call_credentials",
22992295
"composite_channel_credentials",
23002296
"compute_engine_channel_credentials",
2301-
"local_channel_credentials",
2302-
"local_server_credentials",
2303-
"alts_channel_credentials",
2304-
"alts_server_credentials",
2305-
"ssl_server_credentials",
2306-
"ssl_server_certificate_configuration",
23072297
"dynamic_ssl_server_credentials",
2308-
"channel_ready_future",
23092298
"insecure_channel",
2310-
"secure_channel",
2299+
"insecure_server_credentials",
23112300
"intercept_channel",
2312-
"server",
2301+
"local_channel_credentials",
2302+
"local_server_credentials",
2303+
"metadata_call_credentials",
2304+
"method_handlers_generic_handler",
23132305
"protos",
2314-
"services",
23152306
"protos_and_services",
2307+
"secure_channel",
2308+
"server",
2309+
"services",
2310+
"ssl_channel_credentials",
2311+
"ssl_server_certificate_configuration",
2312+
"ssl_server_credentials",
2313+
"stream_stream_rpc_method_handler",
2314+
"stream_unary_rpc_method_handler",
2315+
"unary_stream_rpc_method_handler",
2316+
"unary_unary_rpc_method_handler",
23162317
"xds_channel_credentials",
23172318
"xds_server_credentials",
2318-
"insecure_server_credentials",
23192319
)
23202320

23212321
############################### Extension Shims ################################

src/python/grpcio/grpc/_channel.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,12 +1042,12 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
10421042

10431043
__slots__ = [
10441044
"_channel",
1045+
"_context",
10451046
"_managed_call",
10461047
"_method",
1047-
"_target",
10481048
"_request_serializer",
10491049
"_response_deserializer",
1050-
"_context",
1050+
"_target",
10511051
]
10521052

10531053
# pylint: disable=too-many-arguments
@@ -1218,11 +1218,11 @@ class _SingleThreadedUnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
12181218

12191219
__slots__ = [
12201220
"_channel",
1221+
"_context",
12211222
"_method",
1222-
"_target",
12231223
"_request_serializer",
12241224
"_response_deserializer",
1225-
"_context",
1225+
"_target",
12261226
]
12271227

12281228
# pylint: disable=too-many-arguments
@@ -1319,12 +1319,12 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
13191319

13201320
__slots__ = [
13211321
"_channel",
1322+
"_context",
13221323
"_managed_call",
13231324
"_method",
1324-
"_target",
13251325
"_request_serializer",
13261326
"_response_deserializer",
1327-
"_context",
1327+
"_target",
13281328
]
13291329

13301330
# pylint: disable=too-many-arguments
@@ -1411,12 +1411,12 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
14111411

14121412
__slots__ = [
14131413
"_channel",
1414+
"_context",
14141415
"_managed_call",
14151416
"_method",
1416-
"_target",
14171417
"_request_serializer",
14181418
"_response_deserializer",
1419-
"_context",
1419+
"_target",
14201420
]
14211421

14221422
# pylint: disable=too-many-arguments
@@ -1581,12 +1581,12 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
15811581

15821582
__slots__ = [
15831583
"_channel",
1584+
"_context",
15841585
"_managed_call",
15851586
"_method",
1586-
"_target",
15871587
"_request_serializer",
15881588
"_response_deserializer",
1589-
"_context",
1589+
"_target",
15901590
]
15911591

15921592
# pylint: disable=too-many-arguments

src/python/grpcio/grpc/_compression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def augment_metadata(
6565

6666

6767
__all__ = (
68-
"NoCompression",
6968
"Deflate",
7069
"Gzip",
70+
"NoCompression",
7171
)

src/python/grpcio/grpc/aio/__init__.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,37 @@
5959
################################### __all__ #################################
6060

6161
__all__ = (
62-
"init_grpc_aio",
63-
"shutdown_grpc_aio",
62+
"EOF",
63+
"AbortError",
6464
"AioRpcError",
65-
"RpcContext",
65+
"BaseError",
6666
"Call",
67-
"UnaryUnaryCall",
68-
"UnaryStreamCall",
69-
"StreamUnaryCall",
70-
"StreamStreamCall",
7167
"Channel",
72-
"UnaryUnaryMultiCallable",
73-
"UnaryStreamMultiCallable",
74-
"StreamUnaryMultiCallable",
75-
"StreamStreamMultiCallable",
7668
"ClientCallDetails",
7769
"ClientInterceptor",
78-
"UnaryStreamClientInterceptor",
79-
"UnaryUnaryClientInterceptor",
80-
"StreamUnaryClientInterceptor",
81-
"StreamStreamClientInterceptor",
8270
"InterceptedUnaryUnaryCall",
83-
"ServerInterceptor",
84-
"insecure_channel",
85-
"server",
71+
"InternalError",
72+
"Metadata",
73+
"RpcContext",
8674
"Server",
75+
"ServerInterceptor",
8776
"ServicerContext",
88-
"EOF",
89-
"secure_channel",
90-
"AbortError",
91-
"BaseError",
77+
"StreamStreamCall",
78+
"StreamStreamClientInterceptor",
79+
"StreamStreamMultiCallable",
80+
"StreamUnaryCall",
81+
"StreamUnaryClientInterceptor",
82+
"StreamUnaryMultiCallable",
83+
"UnaryStreamCall",
84+
"UnaryStreamClientInterceptor",
85+
"UnaryStreamMultiCallable",
86+
"UnaryUnaryCall",
87+
"UnaryUnaryClientInterceptor",
88+
"UnaryUnaryMultiCallable",
9289
"UsageError",
93-
"InternalError",
94-
"Metadata",
90+
"init_grpc_aio",
91+
"insecure_channel",
92+
"secure_channel",
93+
"server",
94+
"shutdown_grpc_aio",
9595
)

src/python/grpcio/grpc/aio/_base_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from ._typing import RequestType
3131
from ._typing import ResponseType
3232

33-
__all__ = "RpcContext", "Call", "UnaryUnaryCall", "UnaryStreamCall"
33+
__all__ = "Call", "RpcContext", "UnaryStreamCall", "UnaryUnaryCall"
3434

3535

3636
class RpcContext(metaclass=ABCMeta):

src/python/grpcio/grpc/aio/_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from ._typing import ResponseType
4646
from ._typing import SerializingFunction
4747

48-
__all__ = "AioRpcError", "Call", "UnaryUnaryCall", "UnaryStreamCall"
48+
__all__ = "AioRpcError", "Call", "UnaryStreamCall", "UnaryUnaryCall"
4949

5050
_LOCAL_CANCELLATION_DETAILS = "Locally cancelled by application!"
5151
_GC_CANCELLATION_DETAILS = "Cancelled upon garbage collection!"

src/python/grpcio/grpc/experimental/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def wrap_server_method_handler(wrapper, handler):
127127
from grpc._simple_stubs import unary_unary
128128

129129
__all__ += (
130-
"unary_unary",
131-
"unary_stream",
132-
"stream_unary",
133130
"stream_stream",
131+
"stream_unary",
132+
"unary_stream",
133+
"unary_unary",
134134
)

src/python/grpcio_channelz/grpc_channelz/v1/channelz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def add_channelz_servicer(server):
5555
add_channelz_servicer.__doc__ = _add_channelz_servicer_doc
5656

5757
__all__ = [
58-
"aio",
59-
"add_channelz_servicer",
6058
"ChannelzServicer",
59+
"add_channelz_servicer",
60+
"aio",
6161
]
6262

6363
else:
@@ -70,6 +70,6 @@ def add_channelz_servicer(server):
7070
add_channelz_servicer.__doc__ = _add_channelz_servicer_doc
7171

7272
__all__ = [
73-
"add_channelz_servicer",
7473
"ChannelzServicer",
74+
"add_channelz_servicer",
7575
]

src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def enable_server_reflection(service_names, server, pool=None):
9292
__all__ = [
9393
"SERVICE_NAME",
9494
"ReflectionServicer",
95-
"enable_server_reflection",
9695
"aio",
96+
"enable_server_reflection",
9797
]
9898
else:
9999

0 commit comments

Comments
 (0)
0