From b50c91dc8e5317143d2be93eeb50564bf21e97a9 Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Mon, 25 Oct 2021 10:51:53 -0700 Subject: [PATCH] Satiate stylecheck --- proto/message.py | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/proto/message.py b/proto/message.py index 9de6ad07..3dd22414 100644 --- a/proto/message.py +++ b/proto/message.py @@ -67,9 +67,7 @@ def __new__(mcls, name, bases, attrs): # Determine the name of the entry message. msg_name = "{pascal_key}Entry".format( pascal_key=re.sub( - r"_\w", - lambda m: m.group()[1:].upper(), - key, + r"_\w", lambda m: m.group()[1:].upper(), key, ).replace(key[0], key[0].upper(), 1), ) @@ -85,26 +83,20 @@ def __new__(mcls, name, bases, attrs): { "__module__": attrs.get("__module__", None), "__qualname__": "{prefix}.{name}".format( - prefix=attrs.get("__qualname__", name), - name=msg_name, + prefix=attrs.get("__qualname__", name), name=msg_name, ), "_pb_options": {"map_entry": True}, } ) entry_attrs["key"] = Field(field.map_key_type, number=1) entry_attrs["value"] = Field( - field.proto_type, - number=2, - enum=field.enum, - message=field.message, + field.proto_type, number=2, enum=field.enum, message=field.message, ) map_fields[msg_name] = MessageMeta(msg_name, (Message,), entry_attrs) # Create the repeated field for the entry message. map_fields[key] = RepeatedField( - ProtoType.MESSAGE, - number=field.number, - message=map_fields[msg_name], + ProtoType.MESSAGE, number=field.number, message=map_fields[msg_name], ) # Add the new entries to the attrs @@ -296,13 +288,7 @@ def pb(cls, obj=None, *, coerce: bool = False): if coerce: obj = cls(obj) else: - raise TypeError( - "%r is not an instance of %s" - % ( - obj, - cls.__name__, - ) - ) + raise TypeError("%r is not an instance of %s" % (obj, cls.__name__,)) return obj._pb def wrap(cls, pb): @@ -468,11 +454,7 @@ class Message(metaclass=MessageMeta): """ def __init__( - self, - mapping=None, - *, - ignore_unknown_fields=False, - **kwargs, + self, mapping=None, *, ignore_unknown_fields=False, **kwargs, ): # We accept several things for `mapping`: # * An instance of this class. @@ -513,10 +495,7 @@ def __init__( # Sanity check: Did we get something not a map? Error if so. raise TypeError( "Invalid constructor input for %s: %r" - % ( - self.__class__.__name__, - mapping, - ) + % (self.__class__.__name__, mapping,) ) params = {}