adjust isort config (#4290)

Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
This commit is contained in:
Jelle Zijlstra
2020-06-29 00:00:21 -07:00
committed by GitHub
parent cc8344b8c6
commit 0142a87da8
113 changed files with 112 additions and 234 deletions

View File

@@ -1,5 +1,4 @@
from typing import ClassVar, Iterable, NoReturn, Optional
from typing_extensions import Literal
class Quitter:

View File

@@ -1,6 +1,5 @@
import sys
from typing import Any, Dict, NoReturn, Optional, Sequence, Tuple, Union, overload
from typing_extensions import Literal
CREATE_NEW_CONSOLE: int

View File

@@ -9,7 +9,6 @@
import sys
import typing as _typing
from typing import Any, Iterator, Optional, TypeVar, Union, overload
from typing_extensions import Literal
from _ast import * # type: ignore

View File

@@ -1,5 +1,6 @@
import ssl
import sys
from _typeshed import FileDescriptorLike
from abc import ABCMeta
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle
from asyncio.futures import Future
@@ -8,11 +9,8 @@ from asyncio.tasks import Task
from asyncio.transports import BaseTransport
from socket import _Address, _RetAddress, socket
from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload
from typing_extensions import Literal
from _typeshed import FileDescriptorLike
if sys.version_info >= (3, 7):
from contextvars import Context

View File

@@ -1,6 +1,5 @@
import contextvars
from typing import Callable, List, Sequence, Tuple
from typing_extensions import Literal
from . import futures

View File

@@ -1,8 +1,7 @@
from _typeshed import AnyPath
from types import FrameType
from typing import List, Optional
from _typeshed import AnyPath
from . import tasks
def _task_repr_info(task: tasks.Task) -> List[str]: ... # undocumented

View File

@@ -1,5 +1,6 @@
import ssl
import sys
from _typeshed import FileDescriptorLike
from abc import ABCMeta, abstractmethod
from asyncio.futures import Future
from asyncio.protocols import BaseProtocol
@@ -9,8 +10,6 @@ from asyncio.unix_events import AbstractChildWatcher
from socket import _Address, _RetAddress, socket
from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload
from _typeshed import FileDescriptorLike
if sys.version_info >= (3, 7):
from contextvars import Context

View File

@@ -1,6 +1,5 @@
from socket import socket
from typing import Any, Mapping, Optional
from typing_extensions import Literal
from . import base_events, constants, events, futures, streams, transports

View File

@@ -1,7 +1,6 @@
import ssl
import sys
from typing import Any, Callable, ClassVar, Deque, Dict, List, Optional, Tuple
from typing_extensions import Literal
from . import constants, events, futures, protocols, transports

View File

@@ -17,7 +17,6 @@ from typing import (
Union,
overload,
)
from typing_extensions import Literal
from .events import AbstractEventLoop

View File

@@ -1,7 +1,6 @@
import sys
from typing import Any, Optional, Pattern
from _typeshed import AnyPath
from typing import Any, Optional, Pattern
if sys.version_info < (3, 6):
_SuccessType = bool

View File

@@ -1,4 +1,5 @@
import sys
from _typeshed import AnyPath, StrPath
from typing import (
IO,
AbstractSet,
@@ -21,8 +22,6 @@ from typing import (
overload,
)
from _typeshed import AnyPath, StrPath
# Internal type aliases
_section = Mapping[str, str]
_parser = MutableMapping[str, _section]

View File

@@ -1,7 +1,6 @@
import sys
from types import TracebackType
from typing import Iterator, MutableMapping, Optional, Type, Union
from typing_extensions import Literal
_KeyType = Union[str, bytes]

View File

@@ -1,5 +1,4 @@
import sys
from _typeshed import FileDescriptorLike
def cancel_dump_traceback_later() -> None: ...

View File

@@ -1,10 +1,8 @@
from _typeshed import FileDescriptorLike
from array import array
from typing import Any, Union, overload
from typing_extensions import Literal
from _typeshed import FileDescriptorLike
FASYNC: int
FD_CLOEXEC: int
DN_ACCESS: int

View File

@@ -1,9 +1,7 @@
import sys
from typing import IO, Any, Container, Iterable, Optional, Sequence, Type, TypeVar, Union, overload
from typing_extensions import Literal
from _typeshed import StrPath
from typing import IO, Any, Container, Iterable, Optional, Sequence, Type, TypeVar, Union, overload
from typing_extensions import Literal
class NullTranslations:
def __init__(self, fp: Optional[IO[str]] = ...) -> None: ...

View File

@@ -1,11 +1,9 @@
import _compression
import sys
import zlib
from typing import IO, Optional, TextIO, Union, overload
from typing_extensions import Literal
from _typeshed import AnyPath, ReadableBuffer
from typing import IO, Optional, TextIO, Union, overload
from typing_extensions import Literal
_OpenBinaryMode = Literal["r", "rb", "a", "ab", "w", "wb", "x", "xb"]
_OpenTextMode = Literal["rt", "at", "wt", "xt"]

View File

@@ -1,9 +1,8 @@
# Stubs for hashlib
import sys
from typing import AbstractSet, Optional, Union
from _typeshed import ReadableBuffer
from typing import AbstractSet, Optional, Union
class _Hash(object):
digest_size: int

View File

@@ -1,6 +1,5 @@
import sys
from enum import IntEnum
from typing_extensions import Literal
class HTTPStatus(IntEnum):

View File

@@ -1,6 +1,7 @@
import os
import sys
import types
from _typeshed import StrPath
from typing import IO, Any, List, Optional, Tuple, TypeVar, Union
from _imp import (
@@ -14,7 +15,6 @@ from _imp import (
lock_held as lock_held,
release_lock as release_lock,
)
from _typeshed import StrPath
_T = TypeVar("_T")

View File

@@ -1,12 +1,11 @@
import builtins
import codecs
import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from mmap import mmap
from types import TracebackType
from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, TypeVar, Union
from _typeshed import ReadableBuffer, WriteableBuffer
DEFAULT_BUFFER_SIZE: int
SEEK_SET: int

View File

@@ -1,7 +1,6 @@
import sys
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type, Union
from _typeshed import SupportsRead
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type, Union
from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder
from .encoder import JSONEncoder as JSONEncoder

View File

@@ -1,9 +1,7 @@
import io
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
from typing_extensions import Literal
from _typeshed import AnyPath, ReadableBuffer
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
from typing_extensions import Literal
_OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"]
_OpenTextWritingMode = Literal["wt", "xt", "at"]

View File

@@ -1,7 +1,7 @@
import sys
from ctypes import _CData
from logging import Logger
from multiprocessing import connection, pool, sharedctypes, spawn, synchronize, queues
from multiprocessing import connection, pool, queues, sharedctypes, spawn, synchronize
from multiprocessing.context import (
AuthenticationError as AuthenticationError,
BaseContext,
@@ -16,7 +16,6 @@ from multiprocessing.managers import SyncManager
from multiprocessing.process import active_children as active_children, current_process as current_process
from multiprocessing.spawn import freeze_support as freeze_support
from typing import Any, Callable, Iterable, List, Optional, Sequence, Tuple, Type, Union, overload
from typing_extensions import Literal
if sys.version_info >= (3, 8):

View File

@@ -4,7 +4,6 @@ from logging import Logger
from multiprocessing import queues, sharedctypes, synchronize
from multiprocessing.process import BaseProcess
from typing import Any, Callable, Iterable, List, Optional, Sequence, Type, Union, overload
from typing_extensions import Literal
_LockLike = Union[synchronize.Lock, synchronize.RLock]

View File

@@ -1,4 +1,5 @@
import sys
from _typeshed import AnyPath
from builtins import OSError as error
from io import TextIOWrapper as _TextIOWrapper
from posix import listdir as listdir, times_result
@@ -25,8 +26,6 @@ from typing import (
overload,
)
from _typeshed import AnyPath
from . import path as path
# We need to use something from path, or flake8 and pytype get unhappy

View File

@@ -1,11 +1,10 @@
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
import os
import sys
from _typeshed import AnyPath, BytesPath, StrPath
from genericpath import exists as exists
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload
from _typeshed import AnyPath, BytesPath, StrPath
_T = TypeVar("_T")
if sys.version_info >= (3, 6):

View File

@@ -1,10 +1,9 @@
import os
import sys
from _typeshed import OpenBinaryMode, OpenTextMode
from types import TracebackType
from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union, overload
from _typeshed import OpenBinaryMode, OpenTextMode
_P = TypeVar("_P", bound=PurePath)
if sys.version_info >= (3, 6):

View File

@@ -1,9 +1,8 @@
import sys
from _typeshed import FileDescriptor, FileDescriptorLike
from abc import ABCMeta, abstractmethod
from typing import Any, List, Mapping, NamedTuple, Optional, Tuple
from _typeshed import FileDescriptor, FileDescriptorLike
_EventMask = int
EVENT_READ: _EventMask

View File

@@ -1,11 +1,9 @@
import sys
from _typeshed import AnyPath
from types import TracebackType
from typing import IO, Any, AnyStr, Callable, Generic, Mapping, Optional, Sequence, Tuple, Type, TypeVar, Union, overload
from typing_extensions import Literal
from _typeshed import AnyPath
# We prefer to annotate inputs to methods (eg subprocess.check_call) with these
# union types.
# For outputs we use laborious literal based overloads to try to determine

View File

@@ -2,7 +2,6 @@ import os
import sys
from types import TracebackType
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload
from typing_extensions import Literal
# global variables

View File

@@ -1,9 +1,8 @@
import sys
from _typeshed import AnyPath
from types import SimpleNamespace
from typing import Optional, Sequence
from _typeshed import AnyPath
class EnvBuilder:
system_site_packages: bool
clear: bool

View File

@@ -3,14 +3,12 @@ import http.client
import io
import sys
import time
from _typeshed import SupportsRead, SupportsWrite
from datetime import datetime
from types import TracebackType
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Tuple, Type, Union, overload
from typing_extensions import Literal
from _typeshed import SupportsRead, SupportsWrite
class _SupportsTimeTuple(Protocol):
def timetuple(self) -> time.struct_time: ...