diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 94f64c55..026e15c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: with: python-version: 3.8 - name: Install black - run: pip install black==19.10b0 + run: pip install black==22.3.0 - name: Check diff run: black --diff --check . docs: diff --git a/proto/_file_info.py b/proto/_file_info.py index 34ec79c5..537eeaf4 100644 --- a/proto/_file_info.py +++ b/proto/_file_info.py @@ -40,7 +40,9 @@ def maybe_add_descriptor(cls, filename, package): if not descriptor: descriptor = cls.registry[filename] = cls( descriptor=descriptor_pb2.FileDescriptorProto( - name=filename, package=package, syntax="proto3", + name=filename, + package=package, + syntax="proto3", ), enums=collections.OrderedDict(), messages=collections.OrderedDict(), diff --git a/proto/datetime_helpers.py b/proto/datetime_helpers.py index d73af624..7a3aafec 100644 --- a/proto/datetime_helpers.py +++ b/proto/datetime_helpers.py @@ -171,7 +171,7 @@ def from_rfc3339(cls, stamp): nanos = 0 else: scale = 9 - len(fraction) - nanos = int(fraction) * (10 ** scale) + nanos = int(fraction) * (10**scale) return cls( bare.year, bare.month, diff --git a/proto/fields.py b/proto/fields.py index b5834925..6f5b6452 100644 --- a/proto/fields.py +++ b/proto/fields.py @@ -78,7 +78,8 @@ def descriptor(self): if isinstance(self.message, str): if not self.message.startswith(self.package): self.message = "{package}.{name}".format( - package=self.package, name=self.message, + package=self.package, + name=self.message, ) type_name = self.message elif self.message: @@ -90,7 +91,8 @@ def descriptor(self): elif isinstance(self.enum, str): if not self.enum.startswith(self.package): self.enum = "{package}.{name}".format( - package=self.package, name=self.enum, + package=self.package, + name=self.enum, ) type_name = self.enum elif self.enum: diff --git a/proto/marshal/marshal.py b/proto/marshal/marshal.py index baac7adc..e7f8d4d9 100644 --- a/proto/marshal/marshal.py +++ b/proto/marshal/marshal.py @@ -215,7 +215,8 @@ def to_proto(self, proto_type, value, *, strict: bool = False): raise TypeError( "Parameter must be instance of the same class; " "expected {expected}, got {got}".format( - expected=proto_type.__name__, got=pb_value.__class__.__name__, + expected=proto_type.__name__, + got=pb_value.__class__.__name__, ), ) diff --git a/proto/marshal/rules/dates.py b/proto/marshal/rules/dates.py index 1e0695ec..5145bcf8 100644 --- a/proto/marshal/rules/dates.py +++ b/proto/marshal/rules/dates.py @@ -44,7 +44,8 @@ def to_proto(self, value) -> timestamp_pb2.Timestamp: return value.timestamp_pb() if isinstance(value, datetime): return timestamp_pb2.Timestamp( - seconds=int(value.timestamp()), nanos=value.microsecond * 1000, + seconds=int(value.timestamp()), + nanos=value.microsecond * 1000, ) return value diff --git a/proto/marshal/rules/enums.py b/proto/marshal/rules/enums.py index d965666c..9cfc3127 100644 --- a/proto/marshal/rules/enums.py +++ b/proto/marshal/rules/enums.py @@ -36,7 +36,8 @@ def to_python(self, value, *, absent: bool = None): # the user realizes that an unexpected value came along. warnings.warn( "Unrecognized {name} enum value: {value}".format( - name=self._enum.__name__, value=value, + name=self._enum.__name__, + value=value, ) ) return value diff --git a/proto/marshal/rules/struct.py b/proto/marshal/rules/struct.py index 27dfaf56..0e34587b 100644 --- a/proto/marshal/rules/struct.py +++ b/proto/marshal/rules/struct.py @@ -47,11 +47,15 @@ def to_python(self, value, *, absent: bool = None): return str(value.string_value) if kind == "struct_value": return self._marshal.to_python( - struct_pb2.Struct, value.struct_value, absent=False, + struct_pb2.Struct, + value.struct_value, + absent=False, ) if kind == "list_value": return self._marshal.to_python( - struct_pb2.ListValue, value.list_value, absent=False, + struct_pb2.ListValue, + value.list_value, + absent=False, ) # If more variants are ever added, we want to fail loudly # instead of tacitly returning None. @@ -126,7 +130,9 @@ def to_proto(self, value) -> struct_pb2.Struct: if isinstance(value, struct_pb2.Struct): return value if isinstance(value, maps.MapComposite): - return struct_pb2.Struct(fields={k: v for k, v in value.pb.items()},) + return struct_pb2.Struct( + fields={k: v for k, v in value.pb.items()}, + ) # We got a dict (or something dict-like); convert it. answer = struct_pb2.Struct( diff --git a/proto/message.py b/proto/message.py index 13a7635c..b157f728 100644 --- a/proto/message.py +++ b/proto/message.py @@ -67,7 +67,9 @@ 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), ) @@ -83,20 +85,26 @@ 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 @@ -312,7 +320,13 @@ 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): @@ -478,7 +492,11 @@ 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. @@ -519,7 +537,10 @@ 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 = {} @@ -564,7 +585,7 @@ def __init__( super().__setattr__("_pb", self._meta.pb(**params)) def _get_pb_type_from_key(self, key): - """Given a key, return the corresponding pb_type. + """Given a key, return the corresponding pb_type. Args: key(str): The name of the field. diff --git a/proto/modules.py b/proto/modules.py index 9d2e519e..45864a93 100644 --- a/proto/modules.py +++ b/proto/modules.py @@ -17,7 +17,8 @@ _ProtoModule = collections.namedtuple( - "ProtoModule", ["package", "marshal", "manifest"], + "ProtoModule", + ["package", "marshal", "manifest"], ) @@ -39,7 +40,11 @@ def define_module( """ if not marshal: marshal = package - return _ProtoModule(package=package, marshal=marshal, manifest=frozenset(manifest),) + return _ProtoModule( + package=package, + marshal=marshal, + manifest=frozenset(manifest), + ) __all__ = ("define_module",) diff --git a/setup.py b/setup.py index a68e9856..012a7b7b 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,11 @@ platforms="Posix; MacOS X", include_package_data=True, install_requires=("protobuf >= 3.19.0",), - extras_require={"testing": ["google-api-core[grpc] >= 1.22.2",],}, + extras_require={ + "testing": [ + "google-api-core[grpc] >= 1.22.2", + ], + }, python_requires=">=3.6", classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/tests/clam.py b/tests/clam.py index a4255fe8..4946ebe1 100644 --- a/tests/clam.py +++ b/tests/clam.py @@ -14,7 +14,13 @@ import proto -__protobuf__ = proto.module(package="ocean.clam.v1", manifest={"Clam", "Species",},) +__protobuf__ = proto.module( + package="ocean.clam.v1", + manifest={ + "Clam", + "Species", + }, +) class Species(proto.Enum): diff --git a/tests/conftest.py b/tests/conftest.py index b60b91d2..f1f8a096 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -92,7 +92,9 @@ def _register_messages(scope, iterable, sym_db): """Create and register messages from the file descriptor.""" for name, descriptor in iterable.items(): new_msg = reflection.GeneratedProtocolMessageType( - name, (message.Message,), {"DESCRIPTOR": descriptor, "__module__": None}, + name, + (message.Message,), + {"DESCRIPTOR": descriptor, "__module__": None}, ) sym_db.RegisterMessage(new_msg) setattr(scope, name, new_msg) diff --git a/tests/enums_test.py b/tests/enums_test.py index 6639fbf9..59c5e671 100644 --- a/tests/enums_test.py +++ b/tests/enums_test.py @@ -14,7 +14,12 @@ import proto -__protobuf__ = proto.module(package="test.proto", manifest={"Enums",},) +__protobuf__ = proto.module( + package="test.proto", + manifest={ + "Enums", + }, +) class OneEnum(proto.Enum): diff --git a/tests/mollusc.py b/tests/mollusc.py index d12e4cb9..c92f161a 100644 --- a/tests/mollusc.py +++ b/tests/mollusc.py @@ -15,7 +15,12 @@ import proto import zone -__protobuf__ = proto.module(package="ocean.mollusc.v1", manifest={"Mollusc",},) +__protobuf__ = proto.module( + package="ocean.mollusc.v1", + manifest={ + "Mollusc", + }, +) class Mollusc(proto.Message): diff --git a/tests/test_fields_int.py b/tests/test_fields_int.py index 40f5aa38..81e15e4e 100644 --- a/tests/test_fields_int.py +++ b/tests/test_fields_int.py @@ -65,12 +65,12 @@ class Foo(proto.Message): big = proto.Field(proto.INT64, number=2) foo = Foo() - foo.big = 2 ** 40 - assert foo.big == 2 ** 40 + foo.big = 2**40 + assert foo.big == 2**40 with pytest.raises(ValueError): - foo.small = 2 ** 40 + foo.small = 2**40 with pytest.raises(ValueError): - Foo(small=2 ** 40) + Foo(small=2**40) def test_int_unsigned(): diff --git a/tests/test_fields_map_composite.py b/tests/test_fields_map_composite.py index 13bf0c5f..3b2d8fd9 100644 --- a/tests/test_fields_map_composite.py +++ b/tests/test_fields_map_composite.py @@ -22,7 +22,12 @@ class Foo(proto.Message): bar = proto.Field(proto.INT32, number=1) class Baz(proto.Message): - foos = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message=Foo,) + foos = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message=Foo, + ) baz = Baz(foos={"i": Foo(bar=42), "j": Foo(bar=24)}) assert len(baz.foos) == 2 @@ -36,7 +41,12 @@ class Foo(proto.Message): bar = proto.Field(proto.INT32, number=1) class Baz(proto.Message): - foos = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message=Foo,) + foos = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message=Foo, + ) baz = Baz(foos={"i": {"bar": 42}, "j": {"bar": 24}}) assert len(baz.foos) == 2 @@ -52,7 +62,12 @@ class Foo(proto.Message): bar = proto.Field(proto.INT32, number=1) class Baz(proto.Message): - foos = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message=Foo,) + foos = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message=Foo, + ) baz = Baz() baz.foos["i"] = Foo(bar=42) @@ -68,7 +83,12 @@ class Foo(proto.Message): bar = proto.Field(proto.INT32, number=1) class Baz(proto.Message): - foos = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message=Foo,) + foos = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message=Foo, + ) baz = Baz() baz.foos["i"] = Foo() @@ -82,7 +102,12 @@ class Foo(proto.Message): bar = proto.Field(proto.INT32, number=1) class Baz(proto.Message): - foos = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message=Foo,) + foos = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message=Foo, + ) baz = Baz() baz.foos["i"] = Foo(bar=42) diff --git a/tests/test_fields_repeated_composite.py b/tests/test_fields_repeated_composite.py index 2ce691ef..29c7e9fe 100644 --- a/tests/test_fields_repeated_composite.py +++ b/tests/test_fields_repeated_composite.py @@ -75,7 +75,9 @@ class Baz(proto.Message): def test_repeated_composite_marshaled(): class Foo(proto.Message): timestamps = proto.RepeatedField( - proto.MESSAGE, message=timestamp_pb2.Timestamp, number=1, + proto.MESSAGE, + message=timestamp_pb2.Timestamp, + number=1, ) foo = Foo( diff --git a/tests/test_file_info_salting.py b/tests/test_file_info_salting.py index c7a91d93..4fce9105 100644 --- a/tests/test_file_info_salting.py +++ b/tests/test_file_info_salting.py @@ -34,7 +34,9 @@ def sample_file_info(name): filename, _file_info._FileInfo( descriptor=descriptor_pb2.FileDescriptorProto( - name=filename, package=package, syntax="proto3", + name=filename, + package=package, + syntax="proto3", ), enums=collections.OrderedDict(), messages=collections.OrderedDict(), diff --git a/tests/test_file_info_salting_with_manifest.py b/tests/test_file_info_salting_with_manifest.py index 1fc50462..2d8f75eb 100644 --- a/tests/test_file_info_salting_with_manifest.py +++ b/tests/test_file_info_salting_with_manifest.py @@ -21,7 +21,10 @@ from proto import _file_info, _package_info PACKAGE = "a.test.package.salting.with.manifest" -__protobuf__ = proto.module(package=PACKAGE, manifest={"This", "That"},) +__protobuf__ = proto.module( + package=PACKAGE, + manifest={"This", "That"}, +) class This(proto.Message): @@ -49,7 +52,9 @@ def sample_file_info(name): filename, _file_info._FileInfo( descriptor=descriptor_pb2.FileDescriptorProto( - name=filename, package=package, syntax="proto3", + name=filename, + package=package, + syntax="proto3", ), enums=collections.OrderedDict(), messages=collections.OrderedDict(), diff --git a/tests/test_marshal_types_dates.py b/tests/test_marshal_types_dates.py index 63185893..5fe09ab5 100644 --- a/tests/test_marshal_types_dates.py +++ b/tests/test_marshal_types_dates.py @@ -28,7 +28,9 @@ def test_timestamp_read(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo(event_time=timestamp_pb2.Timestamp(seconds=1335020400)) @@ -45,7 +47,9 @@ class Foo(proto.Message): def test_timestamp_write_init(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo(event_time=DatetimeWithNanoseconds(2012, 4, 21, 15, tzinfo=timezone.utc)) @@ -60,7 +64,9 @@ class Foo(proto.Message): def test_timestamp_write(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo() @@ -77,7 +83,9 @@ class Foo(proto.Message): def test_timestamp_write_pb2(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo() @@ -93,7 +101,9 @@ class Foo(proto.Message): def test_timestamp_rmw_nanos(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo() @@ -110,7 +120,9 @@ class Foo(proto.Message): def test_timestamp_absence(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo() @@ -120,7 +132,9 @@ class Foo(proto.Message): def test_timestamp_del(): class Foo(proto.Message): event_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) foo = Foo(event_time=DatetimeWithNanoseconds(2012, 4, 21, 15, tzinfo=timezone.utc)) @@ -130,7 +144,11 @@ class Foo(proto.Message): def test_duration_read(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo(ttl=duration_pb2.Duration(seconds=60, nanos=1000)) assert isinstance(foo.ttl, timedelta) @@ -142,7 +160,11 @@ class Foo(proto.Message): def test_duration_write_init(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo(ttl=timedelta(days=2)) assert isinstance(foo.ttl, timedelta) @@ -155,7 +177,11 @@ class Foo(proto.Message): def test_duration_write(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo() foo.ttl = timedelta(seconds=120) @@ -167,7 +193,11 @@ class Foo(proto.Message): def test_duration_write_pb2(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo() foo.ttl = duration_pb2.Duration(seconds=120) @@ -179,7 +209,11 @@ class Foo(proto.Message): def test_duration_del(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo(ttl=timedelta(seconds=900)) del foo.ttl @@ -191,7 +225,11 @@ class Foo(proto.Message): def test_duration_nanos_rmw(): class Foo(proto.Message): - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) foo = Foo(ttl=timedelta(microseconds=50)) assert foo.ttl.microseconds == 50 diff --git a/tests/test_marshal_types_enum.py b/tests/test_marshal_types_enum.py index 6cd348c3..02626a8d 100644 --- a/tests/test_marshal_types_enum.py +++ b/tests/test_marshal_types_enum.py @@ -66,7 +66,11 @@ class Bivalve(proto.Enum): OYSTER = 1 class MolluscContainer(proto.Message): - bivalves = proto.RepeatedField(proto.ENUM, number=1, enum=Bivalve,) + bivalves = proto.RepeatedField( + proto.ENUM, + number=1, + enum=Bivalve, + ) mc = MolluscContainer() clam = Bivalve.CLAM @@ -82,7 +86,12 @@ class Bivalve(proto.Enum): OYSTER = 1 class MolluscContainer(proto.Message): - bivalves = proto.MapField(proto.STRING, proto.ENUM, number=1, enum=Bivalve,) + bivalves = proto.MapField( + proto.STRING, + proto.ENUM, + number=1, + enum=Bivalve, + ) mc = MolluscContainer() clam = Bivalve.CLAM diff --git a/tests/test_marshal_types_wrappers_bool.py b/tests/test_marshal_types_wrappers_bool.py index ffe206a6..e27caf99 100644 --- a/tests/test_marshal_types_wrappers_bool.py +++ b/tests/test_marshal_types_wrappers_bool.py @@ -20,7 +20,11 @@ def test_bool_value_init(): class Foo(proto.Message): - bar = proto.Field(proto.MESSAGE, message=wrappers_pb2.BoolValue, number=1,) + bar = proto.Field( + proto.MESSAGE, + message=wrappers_pb2.BoolValue, + number=1, + ) assert Foo(bar=True).bar is True assert Foo(bar=False).bar is False @@ -29,7 +33,11 @@ class Foo(proto.Message): def test_bool_value_init_dict(): class Foo(proto.Message): - bar = proto.Field(proto.MESSAGE, message=wrappers_pb2.BoolValue, number=1,) + bar = proto.Field( + proto.MESSAGE, + message=wrappers_pb2.BoolValue, + number=1, + ) assert Foo({"bar": True}).bar is True assert Foo({"bar": False}).bar is False @@ -38,7 +46,11 @@ class Foo(proto.Message): def test_bool_value_distinction_from_bool(): class Foo(proto.Message): - bar = proto.Field(proto.MESSAGE, message=wrappers_pb2.BoolValue, number=1,) + bar = proto.Field( + proto.MESSAGE, + message=wrappers_pb2.BoolValue, + number=1, + ) baz = proto.Field(proto.BOOL, number=2) assert Foo().bar is None @@ -63,7 +75,11 @@ class Foo(proto.Message): def test_bool_value_write_bool_value(): class Foo(proto.Message): - bar = proto.Field(proto.MESSAGE, message=wrappers_pb2.BoolValue, number=1,) + bar = proto.Field( + proto.MESSAGE, + message=wrappers_pb2.BoolValue, + number=1, + ) foo = Foo(bar=True) foo.bar = wrappers_pb2.BoolValue() @@ -72,7 +88,11 @@ class Foo(proto.Message): def test_bool_value_del(): class Foo(proto.Message): - bar = proto.Field(proto.MESSAGE, message=wrappers_pb2.BoolValue, number=1,) + bar = proto.Field( + proto.MESSAGE, + message=wrappers_pb2.BoolValue, + number=1, + ) foo = Foo(bar=False) assert foo.bar is False diff --git a/tests/test_message_filename_with_and_without_manifest.py b/tests/test_message_filename_with_and_without_manifest.py index 32c2bc15..e67e8472 100644 --- a/tests/test_message_filename_with_and_without_manifest.py +++ b/tests/test_message_filename_with_and_without_manifest.py @@ -16,7 +16,10 @@ PACKAGE = "a.test.package.with.and.without.manifest" -__protobuf__ = proto.module(package=PACKAGE, manifest={"This", "That"},) +__protobuf__ = proto.module( + package=PACKAGE, + manifest={"This", "That"}, +) class This(proto.Message): diff --git a/tests/test_message_filename_with_manifest.py b/tests/test_message_filename_with_manifest.py index e12e5a51..aa96028e 100644 --- a/tests/test_message_filename_with_manifest.py +++ b/tests/test_message_filename_with_manifest.py @@ -15,7 +15,10 @@ import proto PACKAGE = "a.test.package.with.manifest" -__protobuf__ = proto.module(package=PACKAGE, manifest={"ThisFoo", "ThisBar"},) +__protobuf__ = proto.module( + package=PACKAGE, + manifest={"ThisFoo", "ThisBar"}, +) class ThisFoo(proto.Message): diff --git a/tests/test_message_nested.py b/tests/test_message_nested.py index 89dfad68..41af9507 100644 --- a/tests/test_message_nested.py +++ b/tests/test_message_nested.py @@ -56,7 +56,8 @@ class Bacon(proto.Message): baz = proto.Field(proto.MESSAGE, number=2, message=Baz) foo = Foo( - bar={"spam": "xyz", "eggs": False}, baz=Foo.Baz(bacon=Foo.Baz.Bacon(value=42)), + bar={"spam": "xyz", "eggs": False}, + baz=Foo.Baz(bacon=Foo.Baz.Bacon(value=42)), ) assert foo.bar.spam == "xyz" assert not foo.bar.eggs diff --git a/tests/test_modules.py b/tests/test_modules.py index 897ce46c..79a99da1 100644 --- a/tests/test_modules.py +++ b/tests/test_modules.py @@ -38,7 +38,8 @@ class Foo(proto.Message): def test_module_package_explicit_marshal(): sys.modules[__name__].__protobuf__ = proto.module( - package="spam.eggs.v1", marshal="foo", + package="spam.eggs.v1", + marshal="foo", ) try: @@ -54,7 +55,10 @@ class Foo(proto.Message): def test_module_manifest(): - __protobuf__ = proto.module(manifest={"Foo", "Bar", "Baz"}, package="spam.eggs.v1",) + __protobuf__ = proto.module( + manifest={"Foo", "Bar", "Baz"}, + package="spam.eggs.v1", + ) # We want to fake a module, but modules have attribute access, and # `frame.f_locals` is a dictionary. Since we only actually care about diff --git a/tests/zone.py b/tests/zone.py index 4e7ef402..90bea6a8 100644 --- a/tests/zone.py +++ b/tests/zone.py @@ -16,7 +16,12 @@ import proto -__protobuf__ = proto.module(package="ocean.zone.v1", manifest={"Zone",},) +__protobuf__ = proto.module( + package="ocean.zone.v1", + manifest={ + "Zone", + }, +) class Zone(proto.Enum):