Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Open
Description
Feature or enhancement
Proposal:
Now python has warned for const expression that impossible to successfully executed:
>>>1()<python-input-2>:1:SyntaxWarning:'int'objectisnotcallable;perhapsyoumissedacomma?Traceback (mostrecentcalllast):File"<python-input-2>",line1,in<module>1()~^^TypeError:'int'objectisnotcallable>>>1[2]<python-input-3>:1:SyntaxWarning:'int'objectisnotsubscriptable;perhapsyoumissedacomma?Traceback (mostrecentcalllast):File"<python-input-3>",line1,in<module>1[2]~^^^TypeError:'int'objectisnotsubscriptable
This feature want to enable the warning for await expressions:
asyncioREPL3.14.2 (tags/v3.14.2:df79316,Dec52025,17:18:21) [MSCv.194464bit (AMD64)]onwin32Use"await"directlyinsteadof"asyncio.run()".Type"help","copyright","credits"or"license"formoreinformation.>>>importasyncio>>>await1<python-input-0>:1:SyntaxWarning:'int'objectcan'tbeawaitedTraceback (mostrecentcalllast):File"C:\Users\hh180\AppData\Local\Programs\Python\Python314\Lib\concurrent\futures\_base.py",line450,inresultreturnself.__get_result()~~~~~~~~~~~~~~~~~^^File"C:\Users\hh180\AppData\Local\Programs\Python\Python314\Lib\concurrent\futures\_base.py",line395,in__get_resultraiseself._exceptionFile"<python-input-0>",line1,in<module>await1TypeError:'int'objectcan'tbeawaited
As I have known, there is no literal constant type that support for await (int, bool, float, complex, str, list, tuple, dict, set, ellipsis) so if there is only a constant after await we can safely warn it.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Todo