Skip to content

Commit

Permalink
Add __repr__ to streams.EmptyStreamReader
Browse files Browse the repository at this point in the history
  • Loading branch information
elonen committed Sep 15, 2022
1 parent 52fa599 commit ae9e897
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/6916.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add __repr__ to EmptyStreamReader to avoid AttributeErrors.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Jake Davis
Jakob Ackermann
Jakub Wilk
Jan Buchar
Jarno Elonen
Jashandeep Sohi
Jean-Baptiste Estival
Jens Steinhauser
Expand Down
3 changes: 3 additions & 0 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ class EmptyStreamReader(StreamReader): # lgtm [py/missing-call-to-init]
def __init__(self) -> None:
pass

def __repr__(self) -> str:
return "<%s>" % self.__class__.__name__

def exception(self) -> Optional[BaseException]:
return None

Expand Down
1 change: 1 addition & 0 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ async def test_unread_empty(self) -> None:

async def test_empty_stream_reader() -> None:
s = streams.EmptyStreamReader()
assert str(s) is not None
assert s.set_exception(ValueError()) is None
assert s.exception() is None
assert s.feed_eof() is None
Expand Down

0 comments on commit ae9e897

Please sign in to comment.