Skip to content

ast: fix stubtest issues #7877

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

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ class Tuple(expr):
__match_args__ = ("elts", "ctx")
elts: list[expr]
ctx: expr_context
if sys.version_info >= (3, 9):
dims: list[expr]

class expr_context(AST): ...

Expand Down
3 changes: 3 additions & 0 deletions stdlib/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,6 @@ if sys.version_info >= (3, 8):
def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ...

def walk(node: AST) -> Iterator[AST]: ...

if sys.version_info >= (3, 9):
def main() -> None: ...
7 changes: 2 additions & 5 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
_ast.ImportFrom.level
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
_collections_abc.AsyncGenerator.ag_frame
Expand All @@ -8,7 +7,6 @@ _collections_abc.ItemsView.__reversed__
_collections_abc.KeysView.__reversed__
_collections_abc.ValuesView.__reversed__
_weakref.ProxyType.__reversed__ # Doesn't really exist
ast.ImportFrom.level
asyncio.Future.__init__ # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
builtins.dict.get
Expand Down Expand Up @@ -75,7 +73,6 @@ tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable

# Exists at runtime, but missing from stubs
_ast.Tuple.dims
_codecs.unregister
_collections_abc.AsyncIterable.__class_getitem__
_collections_abc.Awaitable.__class_getitem__
Expand All @@ -85,8 +82,6 @@ _collections_abc.MappingView.__class_getitem__
_csv.Reader
_csv.Writer
_imp.source_hash
ast.Tuple.dims
ast.main
asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this
bdb.Breakpoint.clearBreakpoints
distutils.dist.DistributionMetadata.set_classifiers
Expand Down Expand Up @@ -194,6 +189,8 @@ os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all Pat
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime
_ast.ImportFrom.level # None on the class, but never None on instances
ast.ImportFrom.level # None on the class, but never None on instances

# These enums derive from (str, Enum). See comment in py3_common.txt
pstats.SortKey.__new__
Expand Down
7 changes: 2 additions & 5 deletions tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
_ast.ImportFrom.level
_ast.Tuple.dims
_codecs.unregister
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
Expand All @@ -25,9 +23,6 @@ _weakref.ProxyType.__reversed__ # Doesn't really exist
argparse._AppendConstAction.__init__
argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group
argparse._StoreConstAction.__init__
ast.ImportFrom.level
ast.Tuple.dims
ast.main
asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this
asyncio.sslproto.AppProtocolState
asyncio.sslproto.SSLAgainErrors
Expand Down Expand Up @@ -275,6 +270,8 @@ os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all Pat
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime
_ast.ImportFrom.level # None on the class, but never None on instances
ast.ImportFrom.level # None on the class, but never None on instances

# These enums derive from (str, Enum). See comment in py3_common.txt
pstats.SortKey.__new__
Expand Down
7 changes: 2 additions & 5 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
_ast.ImportFrom.level
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
_collections_abc.AsyncGenerator.ag_frame
Expand All @@ -10,7 +9,6 @@ _weakref.ProxyType.__reversed__ # Doesn't really exist
ast.Bytes.__new__
ast.Ellipsis.__new__
ast.ExtSlice.__new__
ast.ImportFrom.level
ast.Index.__new__
ast.NameConstant.__new__
ast.Num.__new__
Expand Down Expand Up @@ -106,15 +104,12 @@ collections.Mapping.get # Adding None to the Union messed up mypy
collections.Sequence.index # Supporting None in end is not mandatory

# Exists at runtime, but missing from stubs
_ast.Tuple.dims
_collections_abc.AsyncIterable.__class_getitem__
_collections_abc.Awaitable.__class_getitem__
_collections_abc.Container.__class_getitem__
_collections_abc.Iterable.__class_getitem__
_collections_abc.MappingView.__class_getitem__
_imp.source_hash
ast.Tuple.dims
ast.main
collections.AsyncIterable.__class_getitem__
collections.Awaitable.__class_getitem__
collections.Container.__class_getitem__
Expand Down Expand Up @@ -196,6 +191,8 @@ xml.etree.cElementTree.XMLParser.__init__

ast.FormattedValue.conversion # None on the class, but never None on instances
_ast.FormattedValue.conversion # None on the class, but never None on instances
_ast.ImportFrom.level # None on the class, but never None on instances
ast.ImportFrom.level # None on the class, but never None on instances

ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem