Skip to content

Commit 16d554d

Browse files
authored
Update black
1 parent 9ef5503 commit 16d554d

File tree

9 files changed

+168
-151
lines changed

9 files changed

+168
-151
lines changed

poetry.lock

Lines changed: 147 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ packages = [
1414
[tool.poetry.dependencies]
1515
python = "^3.6"
1616
backports-datetime-fromisoformat = { version = "^1.0.0", python = "<3.7" }
17-
black = { version = "^19.10b0", optional = true }
17+
black = { version = "^20.8b1", optional = true }
1818
dataclasses = { version = "^0.7", python = ">=3.6, <3.7" }
1919
grpclib = "^0.3.1"
2020
jinja2 = { version = "^2.11.2", optional = true }
2121
protobuf = { version = "^3.12.2", optional = true }
2222

2323
[tool.poetry.dev-dependencies]
24-
black = "^19.10b0"
24+
black = "^20.8b1"
2525
bpython = "^0.19"
2626
grpcio-tools = "^1.30.0"
2727
jinja2 = "^2.11.2"

src/betterproto/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def __setattr__(self, attr: str, value: Any) -> None:
549549
self._group_current[group] = field.name
550550
else:
551551
super().__setattr__(
552-
field.name, self._get_field_default(field.name),
552+
field.name, self._get_field_default(field.name)
553553
)
554554

555555
super().__setattr__(attr, value)
@@ -857,7 +857,7 @@ def to_dict(
857857
field_name=field_name, meta=meta
858858
)
859859
):
860-
output[cased_name] = value.to_dict(casing, include_default_values,)
860+
output[cased_name] = value.to_dict(casing, include_default_values)
861861
elif meta.proto_type == "map":
862862
for k in value:
863863
if hasattr(value[k], "to_dict"):

src/betterproto/compile/importing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def parse_source_type_name(field_type_name):
3636

3737

3838
def get_type_reference(
39-
package: str, imports: set, source_type: str, unwrap: bool = True,
39+
package: str, imports: set, source_type: str, unwrap: bool = True
4040
) -> str:
4141
"""
4242
Return a Python type name for a proto type reference. Adds the import if

src/betterproto/grpc/util/async_channel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class AsyncChannel(AsyncIterable[T]):
8080
or immediately if no source is provided.
8181
"""
8282

83-
def __init__(
84-
self, *, buffer_limit: int = 0, close: bool = False,
85-
):
83+
def __init__(self, *, buffer_limit: int = 0, close: bool = False):
8684
self._queue: asyncio.Queue[Union[T, object]] = asyncio.Queue(buffer_limit)
8785
self._closed = False
8886
self._waiting_receivers: int = 0

src/betterproto/plugin/models.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_comment(proto_file, path: List[int], indent: int = 4) -> str:
130130
# print(list(sci.path), path, file=sys.stderr)
131131
if list(sci.path) == path and sci.leading_comments:
132132
lines = textwrap.wrap(
133-
sci.leading_comments.strip().replace("\n", ""), width=79 - indent,
133+
sci.leading_comments.strip().replace("\n", ""), width=79 - indent
134134
)
135135

136136
if path[-2] == 2 and path[-4] != 6:
@@ -188,7 +188,7 @@ def comment(self) -> str:
188188
for this object.
189189
"""
190190
return get_comment(
191-
proto_file=self.proto_file, path=self.path, indent=self.comment_indent,
191+
proto_file=self.proto_file, path=self.path, indent=self.comment_indent
192192
)
193193

194194

@@ -263,8 +263,7 @@ def python_module_imports(self) -> Set[str]:
263263

264264
@dataclass
265265
class MessageCompiler(ProtoContentBase):
266-
"""Representation of a protobuf message.
267-
"""
266+
"""Representation of a protobuf message."""
268267

269268
parent: Union["MessageCompiler", OutputTemplate] = PLACEHOLDER
270269
proto_obj: DescriptorProto = PLACEHOLDER
@@ -308,8 +307,7 @@ def deprecated_fields(self) -> Iterator[str]:
308307
def is_map(
309308
proto_field_obj: FieldDescriptorProto, parent_message: DescriptorProto
310309
) -> bool:
311-
"""True if proto_field_obj is a map, otherwise False.
312-
"""
310+
"""True if proto_field_obj is a map, otherwise False."""
313311
if proto_field_obj.type == FieldDescriptorProto.TYPE_MESSAGE:
314312
# This might be a map...
315313
message_type = proto_field_obj.type_name.split(".").pop().lower()
@@ -323,8 +321,7 @@ def is_map(
323321

324322

325323
def is_oneof(proto_field_obj: FieldDescriptorProto) -> bool:
326-
"""True if proto_field_obj is a OneOf, otherwise False.
327-
"""
324+
"""True if proto_field_obj is a OneOf, otherwise False."""
328325
if proto_field_obj.HasField("oneof_index"):
329326
return True
330327
return False
@@ -375,8 +372,7 @@ def betterproto_field_args(self) -> List[str]:
375372

376373
@property
377374
def field_wraps(self) -> Union[str, None]:
378-
"""Returns betterproto wrapped field type or None.
379-
"""
375+
"""Returns betterproto wrapped field type or None."""
380376
match_wrapper = re.match(
381377
r"\.google\.protobuf\.(.+)Value", self.proto_obj.type_name
382378
)
@@ -409,8 +405,7 @@ def field_type(self) -> str:
409405

410406
@property
411407
def default_value_string(self) -> Union[Text, None, float, int]:
412-
"""Python representation of the default proto value.
413-
"""
408+
"""Python representation of the default proto value."""
414409
if self.repeated:
415410
return "[]"
416411
if self.py_type == "int":
@@ -499,10 +494,10 @@ def __post_init__(self):
499494
if nested.options.map_entry:
500495
# Get Python types
501496
self.py_k_type = FieldCompiler(
502-
parent=self, proto_obj=nested.field[0], # key
497+
parent=self, proto_obj=nested.field[0] # key
503498
).py_type
504499
self.py_v_type = FieldCompiler(
505-
parent=self, proto_obj=nested.field[1], # value
500+
parent=self, proto_obj=nested.field[1] # value
506501
).py_type
507502
# Get proto types
508503
self.proto_k_type = self.proto_obj.Type.Name(nested.field[0].type)

src/betterproto/plugin/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def read_protobuf_service(
166166
service: ServiceDescriptorProto, index: int, output_package: OutputTemplate
167167
) -> None:
168168
service_data = ServiceCompiler(
169-
parent=output_package, proto_obj=service, path=[6, index],
169+
parent=output_package, proto_obj=service, path=[6, index]
170170
)
171171
for j, method in enumerate(service.method):
172172
ServiceMethodCompiler(
173-
parent=service_data, proto_obj=method, path=[6, index, 2, j],
173+
parent=service_data, proto_obj=method, path=[6, index, 2, j]
174174
)

tests/grpc/test_grpclib_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def test_service_call_with_upfront_request_params():
106106
deadline = grpclib.metadata.Deadline.from_timeout(22)
107107
metadata = {"authorization": "12345"}
108108
async with ChannelFor(
109-
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata),)]
109+
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata))]
110110
) as channel:
111111
await _test_client(
112112
ThingServiceClient(channel, deadline=deadline, metadata=metadata)
@@ -117,7 +117,7 @@ async def test_service_call_with_upfront_request_params():
117117
deadline = grpclib.metadata.Deadline.from_timeout(timeout)
118118
metadata = {"authorization": "12345"}
119119
async with ChannelFor(
120-
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata),)]
120+
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata))]
121121
) as channel:
122122
await _test_client(
123123
ThingServiceClient(channel, timeout=timeout, metadata=metadata)
@@ -134,7 +134,7 @@ async def test_service_call_lower_level_with_overrides():
134134
kwarg_deadline = grpclib.metadata.Deadline.from_timeout(28)
135135
kwarg_metadata = {"authorization": "12345"}
136136
async with ChannelFor(
137-
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata),)]
137+
[ThingService(test_hook=_assert_request_meta_received(deadline, metadata))]
138138
) as channel:
139139
client = ThingServiceClient(channel, deadline=deadline, metadata=metadata)
140140
response = await client._unary_unary(

tests/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def protoc(
4242
*[p.as_posix() for p in path.glob("*.proto")],
4343
]
4444
proc = await asyncio.create_subprocess_exec(
45-
*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
45+
*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
4646
)
4747
stdout, stderr = await proc.communicate()
4848
return stdout, stderr, proc.returncode

0 commit comments

Comments
 (0)