From fbb89f9fd54566e292a63b80cb32053bd6eb1bb4 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 17 Nov 2021 16:29:44 +0000 Subject: [PATCH] Fix isort w.r.t. `_ast`/`_collections_abc`/`_tracemalloc`/`_warnings` (#6329) --- pyproject.toml | 4 ++++ stdlib/@python2/ast.pyi | 3 +-- stdlib/@python2/warnings.pyi | 3 +-- stdlib/ast.pyi | 3 +-- stdlib/builtins.pyi | 5 ++--- stdlib/collections/__init__.pyi | 3 +-- stdlib/tracemalloc.pyi | 3 +-- stdlib/warnings.pyi | 3 +-- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fbe58f2b4..cbdab2954 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,12 +13,16 @@ extra_standard_library = [ "typing_extensions", "_typeshed", # Extra modules not recognized by isort + "_ast", + "_collections_abc", "_compression", "_csv", "_curses", "_markupbase", "_random", "_tkinter", + "_tracemalloc", + "_warnings", "_weakrefset", "genericpath", "opcode", diff --git a/stdlib/@python2/ast.pyi b/stdlib/@python2/ast.pyi index ec370e1a6..b86e38dce 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -4,10 +4,9 @@ # from _ast below when loaded in an unorthodox way by the Dropbox # internal Bazel integration. import typing as _typing -from typing import Any, Iterator - from _ast import * from _ast import AST, Module +from typing import Any, Iterator def parse(source: str | unicode, filename: str | unicode = ..., mode: str | unicode = ...) -> Module: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index e3540ed60..0d187bf70 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -1,9 +1,8 @@ +from _warnings import warn as warn, warn_explicit as warn_explicit from types import ModuleType, TracebackType from typing import List, TextIO, Type, overload from typing_extensions import Literal -from _warnings import warn as warn, warn_explicit as warn_explicit - def showwarning( message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 1649e4ab4..00c62c30c 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -8,11 +8,10 @@ # sys. import sys import typing as _typing +from _ast import * # type: ignore from typing import Any, Iterator, TypeVar, overload from typing_extensions import Literal -from _ast import * # type: ignore - if sys.version_info >= (3, 8): class Num(Constant): value: complex diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 9d309dbbb..0b952f1e6 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1,5 +1,7 @@ import sys import types +from _ast import AST +from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import ( OpenBinaryMode, OpenBinaryModeReading, @@ -59,9 +61,6 @@ from typing import ( ) from typing_extensions import Literal, SupportsIndex, TypeGuard, final -from _ast import AST -from _collections_abc import dict_items, dict_keys, dict_values - if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 17ff45f5a..9b26a756c 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,10 +1,9 @@ import sys +from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import Self from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload from typing_extensions import final -from _collections_abc import dict_items, dict_keys, dict_values - if sys.version_info >= (3, 10): from typing import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Reversible, Sequence else: diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index e812b8247..ca4d5901b 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,7 +1,6 @@ import sys -from typing import Optional, Sequence, Tuple, Union, overload - from _tracemalloc import * +from typing import Optional, Sequence, Tuple, Union, overload def get_object_traceback(obj: object) -> Traceback | None: ... def take_snapshot() -> Snapshot: ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index f6ab5a456..b1c9f4dda 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,9 +1,8 @@ +from _warnings import warn as warn, warn_explicit as warn_explicit from types import ModuleType, TracebackType from typing import Any, Sequence, TextIO, Type, overload from typing_extensions import Literal -from _warnings import warn as warn, warn_explicit as warn_explicit - _ActionKind = Literal["default", "error", "ignore", "always", "module", "once"] filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate