Skip to content

Commit 2b6aaa2

Browse files
haydenbakerJordonPhillips
authored andcommitted
Add formatting check, run it
1 parent 90c8215 commit 2b6aaa2

File tree

12 files changed

+38
-24
lines changed

12 files changed

+38
-24
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ lint-py: ## Runs linters and formatters on the python packages.
2828
check-py: ## Runs checks (formatting, lints, type-checking) on the python packages.
2929
uv run docformatter packages
3030
uv run ruff check packages
31+
uv run ruff format --check
3132
uv run pyright packages
3233

3334

packages/aws-event-stream/src/aws_event_stream/_private/serializers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def _get_payload_media_type(self, schema: Schema, default: str) -> str:
159159

160160

161161
class EventHeaderSerializer(SpecificShapeSerializer):
162-
163162
def __init__(self, encoder: EventHeaderEncoder) -> None:
164163
self._encoder = encoder
165164

packages/aws-event-stream/src/aws_event_stream/aio/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323

2424
class AWSDuplexEventStream[
25-
I: SerializeableShape, O: DeserializeableShape, R: DeserializeableShape
25+
I: SerializeableShape,
26+
O: DeserializeableShape,
27+
R: DeserializeableShape,
2628
](DuplexEventStream[I, O, R]):
2729
"""A duplex event stream using the application/vnd.amazon.eventstream format."""
2830

packages/aws-event-stream/tests/unit/_private/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,7 @@ def serialize(self, serializer: ShapeSerializer):
335335
serializer.write_struct(SCHEMA_EVENT_STREAM, self)
336336

337337
def serialize_members(self, serializer: ShapeSerializer):
338-
serializer.write_struct(
339-
SCHEMA_EVENT_STREAM.members["blobPayload"], self.value
340-
)
338+
serializer.write_struct(SCHEMA_EVENT_STREAM.members["blobPayload"], self.value)
341339

342340

343341
@dataclass
@@ -393,7 +391,13 @@ def serialize_members(self, serializer: ShapeSerializer):
393391
raise SmithyException("Unknown union variants may not be serialized.")
394392

395393

396-
type EventStream = EventStreamMessageEvent | EventStreamPayloadEvent | EventStreamBlobPayloadEvent | EventStreamErrorEvent | EventStreamUnknownEvent
394+
type EventStream = (
395+
EventStreamMessageEvent
396+
| EventStreamPayloadEvent
397+
| EventStreamBlobPayloadEvent
398+
| EventStreamErrorEvent
399+
| EventStreamUnknownEvent
400+
)
397401

398402

399403
class EventStreamDeserializer:

packages/aws-event-stream/tests/unit/test_events.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
b"\x00\x00\x00\x10" # total length
3838
b"\x00\x00\x00\x00" # headers length
3939
b"\x05\xc2\x48\xeb" # prelude crc
40-
b"\x7D\x98\xc8\xff" # message crc
40+
b"\x7d\x98\xc8\xff" # message crc
4141
),
4242
Event(
4343
prelude=EventPrelude(
@@ -407,7 +407,7 @@
407407
CORRUPTED_HEADERS_LENGTH = (
408408
(
409409
b"\x00\x00\x00\x3d" # total length
410-
b"\xFF\x00\x01\x02" # headers length
410+
b"\xff\x00\x01\x02" # headers length
411411
b"\x07\xfd\x83\x96" # prelude crc
412412
b"\x0ccontent-type\x07\x00\x10application/json" # headers
413413
b"{'foo':'bar'}" # payload
@@ -443,7 +443,7 @@
443443
(
444444
b"\x00\x00\x00\x1d" # total length
445445
b"\x00\x00\x00\x00" # headers length
446-
b"\xfd\x52\x8c\x5A" # prelude crc
446+
b"\xfd\x52\x8c\x5a" # prelude crc
447447
b"{'foo':'bar'\x8d" # payload
448448
b"\xc3\x65\x39\x36" # message crc
449449
),
@@ -464,11 +464,11 @@
464464
INVALID_HEADERS_LENGTH = (
465465
(
466466
b"\x00\x00\x00\x3d" # total length
467-
b"\xFF\x00\x01\x02" # headers length
467+
b"\xff\x00\x01\x02" # headers length
468468
b"\x15\x83\xf5\xc2" # prelude crc
469469
b"\x0ccontent-type\x07\x00\x10application/json" # headers
470470
b"{'foo':'bar'}" # payload
471-
b"\x2F\x37\x7f\x5d" # message crc
471+
b"\x2f\x37\x7f\x5d" # message crc
472472
),
473473
InvalidHeadersLength,
474474
)

packages/smithy-core/src/smithy_core/aio/types.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def read(self, size: int = -1) -> bytes:
4646
if self._closed or not self._data:
4747
raise ValueError("I/O operation on closed file.")
4848

49-
if isinstance(self._data, BytesReader) and not iscoroutinefunction( # type: ignore - TODO(pyright)
49+
if isinstance(self._data, BytesReader) and not iscoroutinefunction( # type: ignore - TODO(pyright)
5050
self._data.read
5151
):
5252
# Python's runtime_checkable can't actually tell the difference between
@@ -135,7 +135,7 @@ def __init__(self, data: StreamingBlob):
135135
if isinstance(data, bytes | bytearray):
136136
self._buffer = BytesIO(data)
137137
self._data_source = None
138-
elif isinstance(data, AsyncByteStream) and iscoroutinefunction(data.read): # type: ignore - TODO(pyright)
138+
elif isinstance(data, AsyncByteStream) and iscoroutinefunction(data.read): # type: ignore - TODO(pyright)
139139
# Note that we need that iscoroutine check because python won't actually check
140140
# whether or not the read function is async.
141141
self._buffer = BytesIO()
@@ -321,7 +321,6 @@ async def write(self, data: bytes) -> None:
321321
# Acquire a lock on the data buffer, releasing it automatically when the
322322
# block exits.
323323
async with self._data_condition:
324-
325324
# Wait for the number of chunks in the buffer to be less than the
326325
# specified maximum. This also releases the lock until that condition
327326
# is met.
@@ -407,7 +406,6 @@ async def __anext__(self) -> bytes:
407406
# Acquire a lock on the data buffer, releasing it automatically when the
408407
# block exits.
409408
async with self._data_condition:
410-
411409
# Wait for the stream to be closed or for the data buffer to be non-empty.
412410
# This also releases the lock until that condition is met.
413411
await self._data_condition.wait_for(

packages/smithy-core/src/smithy_core/codecs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def serialize(self, shape: "SerializeableShape") -> bytes:
5050
stream.seek(0)
5151
return stream.read()
5252

53-
def deserialize[
54-
S: DeserializeableShape
55-
](self, source: bytes | BytesReader, shape: type[S]) -> S:
53+
def deserialize[S: DeserializeableShape](
54+
self, source: bytes | BytesReader, shape: type[S]
55+
) -> S:
5656
"""Deserialize bytes into a shape.
5757
5858
:param source: The bytes to deserialize.

packages/smithy-core/src/smithy_core/rfc3986.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
https://github.com/python-hyper/rfc3986/blob/main/src/rfc3986/abnf_regexp.py
1717
https://github.com/python-hyper/rfc3986/blob/main/src/rfc3986/misc.py
1818
"""
19+
1920
import re
2021

2122
# #########################

packages/smithy-core/tests/unit/aio/test_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ async def test_aexit_flushes() -> None:
485485
# Use the provider in a context manager. When this exits, it should flush
486486
# and close the provider.
487487
async with provider:
488-
489488
# Write some data to the provider.
490489
await provider.write(b"foo")
491490

packages/smithy-core/tests/unit/test_documents.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ def test_document_serializer(given: Any, expected: Document):
855855
if v is None:
856856
map_serializer.entry(k, lambda vs: vs.write_null(member_schema))
857857
else:
858-
map_serializer.entry(k, lambda vs: vs.write_string(member_schema, v)) # type: ignore
858+
map_serializer.entry(
859+
k, lambda vs: vs.write_string(member_schema, v)
860+
) # type: ignore
859861
case DocumentSerdeShape():
860862
given.serialize(serializer)
861863
case _:

0 commit comments

Comments
 (0)