You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm 51% sure this belongs in typeshed, 49% sure this belongs in cpython, and 106.88% surely confused.
The 3.9 interpreter says ast.alias._attributes = (), however, the stub says **kwargs: Unpack[_Attributes], therefore, at the very least, there is conflicting information.
Evidence the stub file should change I am confused about what should change
I checked whether ast.alias.lineno exists in Python 3.9.
Python 3.9
(.309) C:\clones\typeshed>py
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> source ='from pathlib import Path'
>>> astModule = ast.parse(source)
>>> for node in ast.walk(astModule):
... ifisinstance(node, ast.alias):
... print(node.lineno)
...
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
AttributeError: 'alias' object has no attribute 'lineno'
Python 3.12
I compared to Python 3.12 just to make sure.
(.venv) C:\clones\typeshed>py
Python 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> source ='from pathlib import Path'
>>> astModule = ast.parse(source)
>>> for node in ast.walk(astModule):
... ifisinstance(node, ast.alias):
... print(node.lineno)
...
1
Obviously, the stub file is off
I compared the actual interpreter behaviors to the stub file, so the situation is clear, right?
But, just to be thorough...
Just in case, I wrote some code to look at the "_attributes" from a few different angles. I thought it would reinforce what I had found. Instead, I am unsure which source is reporting inaccurate information, and I don't know what one should investigate next.
I'm 51% sure this belongs in typeshed, 49% sure this belongs in cpython, and 106.88% surely confused.
The 3.9 interpreter says
ast.alias._attributes = ()
, however, the stub says**kwargs: Unpack[_Attributes]
, therefore, at the very least, there is conflicting information.typeshed/stdlib/ast.pyi
Lines 1431 to 1444 in a7ae4ec
Evidence
the stub file should changeI am confused about what should changeI checked whether
ast.alias.lineno
exists in Python 3.9.Python 3.9
Python 3.12
I compared to Python 3.12 just to make sure.
Obviously, the stub file is off
I compared the actual interpreter behaviors to the stub file, so the situation is clear, right?
But, just to be thorough...
Just in case, I wrote some code to look at the "_attributes" from a few different angles. I thought it would reinforce what I had found. Instead, I am unsure which source is reporting inaccurate information, and I don't know what one should investigate next.
The full output
The text was updated successfully, but these errors were encountered: