ast: fix stubtest issues (#7877)

Add annotations for `_ast.Tuple.dims` and `ast.main()`. Add allowlist comments for others.
This commit is contained in:
Jelle Zijlstra
2022-05-19 02:13:08 -07:00
committed by GitHub
parent d389b5f9cb
commit 250f3d92e7
5 changed files with 11 additions and 15 deletions

View File

@@ -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): ...

View File

@@ -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: ...

View File

@@ -1,4 +1,3 @@
_ast.ImportFrom.level
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
_collections_abc.AsyncGenerator.ag_frame
@@ -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
@@ -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__
@@ -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
@@ -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__

View File

@@ -1,5 +1,3 @@
_ast.ImportFrom.level
_ast.Tuple.dims
_codecs.unregister
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
@@ -23,9 +21,6 @@ _operator.itemgetter.__vectorcalloffset__
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
@@ -261,6 +256,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__

View File

@@ -1,4 +1,3 @@
_ast.ImportFrom.level
_collections_abc.AsyncGenerator.ag_await
_collections_abc.AsyncGenerator.ag_code
_collections_abc.AsyncGenerator.ag_frame
@@ -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__
@@ -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__
@@ -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