Skip to content

Commit

Permalink
Satiate stylecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
software-dov committed Oct 25, 2021
1 parent 6966256 commit b50c91d
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions proto/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit b50c91d

Please sign in to comment.