Skip to content

Commit 7f2b6e6

Browse files
committed
General consistency fixes
1 parent cf29869 commit 7f2b6e6

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/betterproto/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .casing import camel_case, safe_snake_case, snake_case
2727
from .grpc.grpclib_client import ServiceStub
2828

29-
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
29+
if sys.version_info < (3, 7):
3030
# Apply backport of datetime.fromisoformat from 3.7
3131
from backports.datetime_fromisoformat import MonkeyPatch
3232

@@ -984,8 +984,8 @@ def which_one_of(message: Message, group_name: str) -> Tuple[str, Any]:
984984
"""Return the name and value of a message's one-of field group."""
985985
field_name = message._group_current.get(group_name)
986986
if not field_name:
987-
return ("", None)
988-
return (field_name, getattr(message, field_name))
987+
return "", None
988+
return field_name, getattr(message, field_name)
989989

990990

991991
# Circular import workaround: google.protobuf depends on base classes defined above.

src/betterproto/grpc/util/async_channel.py

-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ class ChannelClosed(Exception):
99
An exception raised on an attempt to send through a closed channel
1010
"""
1111

12-
pass
13-
1412

1513
class ChannelDone(Exception):
1614
"""
1715
An exception raised on an attempt to send receive from a channel that is both closed
1816
and empty.
1917
"""
2018

21-
pass
22-
2319

2420
class AsyncChannel(AsyncIterable[T]):
2521
"""

src/betterproto/plugin/models.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def get_field_string(self, indent: int = 4) -> str:
486486
name = f"{self.py_name}"
487487
annotations = f": {self.annotation}"
488488
betterproto_field_type = (
489-
f"betterproto.map_field("
489+
"betterproto.map_field("
490490
f"{self.proto_obj.number}, betterproto.{self.proto_k_type}, "
491491
f"betterproto.{self.proto_v_type})"
492492
)
@@ -634,10 +634,7 @@ def proto_name(self) -> str:
634634

635635
@property
636636
def route(self) -> str:
637-
return (
638-
f"/{self.output_file.package}."
639-
f"{self.parent.proto_name}/{self.proto_name}"
640-
)
637+
return f"/{self.output_file.package}.{self.parent.proto_name}/{self.proto_name}"
641638

642639
@property
643640
def py_input_message(self) -> Union[None, MessageCompiler]:

0 commit comments

Comments
 (0)