Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reword error message for unawaitable types #114091

Closed
swfarnsworth opened this issue Jan 15, 2024 · 0 comments
Closed

Reword error message for unawaitable types #114091

swfarnsworth opened this issue Jan 15, 2024 · 0 comments
Labels
topic-asyncio type-feature A feature request or enhancement

Comments

@swfarnsworth
Copy link
Contributor

swfarnsworth commented Jan 15, 2024

Feature or enhancement

Proposal:

Currently, attempting to await something that cannot be awaited results in this error message:

import asyncio

async def main():
    await 1

asyncio.run(main())

# TypeError: object int can't be used in 'await' expression

I recently encountered this for the first time when the unawaitable object was a method (which was not being called), and found the phrase "object method" unclear. This PR changes the error message so that the name of the class precedes the word "object" and appears in single quotes. A similar construction appears elsewhere in the code base.

>>> 1[2]
TypeError: 'int' object is not subscriptable

The PR already exists at #114090 but will be amended momentarily to implement changes suggested by Jelle and to resolve failed tests.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@swfarnsworth swfarnsworth added the type-feature A feature request or enhancement label Jan 15, 2024
kumaraditya303 pushed a commit that referenced this issue Jun 17, 2024
Reword error message for unawaitable types.
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-asyncio type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

3 participants