Skip to content

Fix return type of asyncio.StreamReader.exception#15756

Merged
srittau merged 2 commits into
python:mainfrom
rijenkii:main
May 11, 2026
Merged

Fix return type of asyncio.StreamReader.exception#15756
srittau merged 2 commits into
python:mainfrom
rijenkii:main

Conversation

@rijenkii
Copy link
Copy Markdown
Contributor

According to typeshed, function asyncio.StreamReader.exception returns Exception. This is provably incorrect:

asyncio REPL 3.14.4 (main, Apr 16 2026, 00:00:00) [GCC 15.2.1 20260123 (Red Hat 15.2.1-7)] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> reader = asyncio.StreamReader()
>>> type(reader.exception())
<class 'NoneType'>

This PR fixes return type of asyncio.StreamReader.exception, making it a union of Exception and None.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit c23cf15 into python:main May 11, 2026
56 checks passed
tkem pushed a commit to tkem/typeshed that referenced this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants