-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
Now python has warned for const expression that impossible to successfully executed:
>>> 1()
<python-input-2>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
1()
~^^
TypeError: 'int' object is not callable
>>> 1[2]
<python-input-3>:1: SyntaxWarning: 'int' object is not subscriptable; perhaps you missed a comma?
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
1[2]
~^^^
TypeError: 'int' object is not subscriptableThis feature want to enable the warning for await expressions:
asyncio REPL 3.14.2 (tags/v3.14.2:df79316, Dec 5 2025, 17:18:21) [MSC v.1944 64 bit (AMD64)] on win32
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> await 1
<python-input-0>:1: SyntaxWarning: 'int' object can't be awaited
Traceback (most recent call last):
File "C:\Users\hh180\AppData\Local\Programs\Python\Python314\Lib\concurrent\futures\_base.py", line 450, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "C:\Users\hh180\AppData\Local\Programs\Python\Python314\Lib\concurrent\futures\_base.py", line 395, in __get_result
raise self._exception
File "<python-input-0>", line 1, in <module>
await 1
TypeError: 'int' object can't be awaitedAs 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
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Todo