Skip to content
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

adjust isort config #4290

Merged
merged 3 commits into from
Jun 29, 2020
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- name: "black"
install: pip install $(grep black requirements-tests-py3.txt)
script: black --check --diff stdlib third_party
allow_failures:
- name: "isort"
install: pip install $(grep isort requirements-tests-py3.txt)
script: isort --check-only --diff --recursive stdlib third_party
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ force_grid_wrap = 0
use_parentheses = true
combine_as_imports = true
line_length = 130
default_section = "THIRDPARTY"
known_standard_library = ["typing_extensions", "_typeshed", "_compression", "_markupbase", "opcode"]
3 changes: 1 addition & 2 deletions stdlib/2/ConfigParser.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union

from _typeshed import SupportsReadline
from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union

DEFAULTSECT: str
MAX_INTERPOLATION_DEPTH: int
Expand Down
22 changes: 10 additions & 12 deletions stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
# Python 3, and stub files conform to Python 3 syntax.

import sys
from _typeshed import (
AnyPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
SupportsWrite,
)
from abc import ABCMeta
from ast import AST, mod
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
Expand Down Expand Up @@ -46,20 +56,8 @@ from typing import (
ValuesView,
overload,
)

from typing_extensions import Literal

from _typeshed import (
AnyPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
SupportsWrite,
)

if sys.version_info >= (3,):
from typing import SupportsBytes, SupportsRound

Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/compileall.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Optional, Pattern

from _typeshed import AnyPath
from typing import Any, Optional, Pattern

# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/fcntl.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Union

from _typeshed import FileDescriptorLike
from typing import Any, Union

FASYNC: int
FD_CLOEXEC: int
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/json.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type, Union

from _typeshed import SupportsRead
from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type, Union

class JSONDecodeError(ValueError):
def dumps(self, obj: Any) -> str: ...
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/os/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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, stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/os/path.pyi
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2/os2emxpath.pyi
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
1 change: 0 additions & 1 deletion stdlib/2and3/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import array
import mmap
import sys
from typing import Protocol, Text, TypeVar, Union

from typing_extensions import Literal

_T_co = TypeVar("_T_co", covariant=True)
Expand Down
1 change: 0 additions & 1 deletion stdlib/2and3/aifc.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from types import TracebackType
from typing import IO, Any, List, NamedTuple, Optional, Text, Tuple, Type, Union, overload

from typing_extensions import Literal

class Error(Exception): ...
Expand Down
1 change: 0 additions & 1 deletion stdlib/2and3/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import sys
from typing import Any, BinaryIO, Generic, Iterable, Iterator, List, MutableSequence, Text, Tuple, TypeVar, Union, overload

from typing_extensions import Literal

_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/asyncore.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import sys
from _typeshed import FileDescriptorLike
from socket import SocketType
from typing import Any, Dict, Optional, Tuple, Union, overload

from _typeshed import FileDescriptorLike

# cyclic dependence with asynchat
_maptype = Dict[int, Any]

Expand Down
22 changes: 10 additions & 12 deletions stdlib/2and3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
# Python 3, and stub files conform to Python 3 syntax.

import sys
from _typeshed import (
AnyPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
SupportsWrite,
)
from abc import ABCMeta
from ast import AST, mod
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
Expand Down Expand Up @@ -46,20 +56,8 @@ from typing import (
ValuesView,
overload,
)

from typing_extensions import Literal

from _typeshed import (
AnyPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
SupportsWrite,
)

if sys.version_info >= (3,):
from typing import SupportsBytes, SupportsRound

Expand Down
4 changes: 1 addition & 3 deletions stdlib/2and3/bz2.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import io
import sys
from _typeshed import AnyPath
from typing import IO, Any, Optional, TextIO, TypeVar, Union, overload

from typing_extensions import Literal

from _typeshed import AnyPath

_PathOrFile = Union[AnyPath, IO[bytes]]
_T = TypeVar("_T")

Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/cProfile.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from typing import Any, Callable, Dict, Optional, TypeVar, Union

from _typeshed import AnyPath
from typing import Any, Callable, Dict, Optional, TypeVar, Union

def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
def runctx(
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/cgitb.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from _typeshed import AnyPath
from types import FrameType, TracebackType
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type

from _typeshed import AnyPath

_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]

def reset() -> str: ... # undocumented
Expand Down
1 change: 0 additions & 1 deletion stdlib/2and3/codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ from typing import (
Union,
overload,
)

from typing_extensions import Literal

# TODO: this only satisfies the most common interface, where
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/fileinput.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union

from _typeshed import AnyPath
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union

if sys.version_info >= (3, 8):
def input(
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/ftplib.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import SupportsRead, SupportsReadline
from socket import socket
from ssl import SSLContext
from types import TracebackType
Expand All @@ -20,8 +21,6 @@ from typing import (
Union,
)

from _typeshed import SupportsRead, SupportsReadline

_T = TypeVar("_T")
_IntOrStr = Union[int, Text]

Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/hmac.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Stubs for hmac

import sys
from _typeshed import ReadableBuffer
from types import ModuleType
from typing import Any, AnyStr, Callable, Optional, Union, overload

from _typeshed import ReadableBuffer

_B = Union[bytes, bytearray]

# TODO more precise type for object of hashlib
Expand Down
1 change: 0 additions & 1 deletion stdlib/2and3/imaplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import time
from socket import socket as _socket
from ssl import SSLContext, SSLSocket
from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Text, Tuple, Type, Union

from typing_extensions import Literal

# TODO: Commands should use their actual return types, not this type alias.
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/lib2to3/pgen2/driver.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from _typeshed import StrPath
from lib2to3.pgen2.grammar import Grammar
from lib2to3.pytree import _NL, _Convert
from logging import Logger
from typing import IO, Any, Iterable, Optional, Text

from _typeshed import StrPath

class Driver:
grammar: Grammar
logger: Logger
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/lib2to3/pgen2/grammar.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Dict, List, Optional, Text, Tuple, TypeVar

from _typeshed import StrPath
from typing import Dict, List, Optional, Text, Tuple, TypeVar

_P = TypeVar("_P")
_Label = Tuple[int, Optional[Text]]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/lib2to3/pgen2/pgen.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from _typeshed import StrPath
from lib2to3.pgen2 import grammar
from lib2to3.pgen2.tokenize import _TokenInfo
from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple

from _typeshed import StrPath

class PgenGrammar(grammar.Grammar): ...

class ParserGenerator:
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/logging/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import threading
from _typeshed import StrPath
from string import Template
from time import struct_time
from types import FrameType, TracebackType
Expand All @@ -20,8 +21,6 @@ from typing import (
overload,
)

from _typeshed import StrPath

_SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tuple[None, None, None]]
if sys.version_info >= (3, 5):
_ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/logging/config.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import sys
from _typeshed import AnyPath, StrPath
from threading import Thread
from typing import IO, Any, Callable, Dict, Optional, Union

from _typeshed import AnyPath, StrPath

if sys.version_info >= (3,):
from configparser import RawConfigParser
else:
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/logging/handlers.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import datetime
import ssl
import sys
from _typeshed import StrPath
from logging import FileHandler, Handler, LogRecord
from socket import SocketType
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload

from _typeshed import StrPath

if sys.version_info >= (3, 7):
from queue import SimpleQueue, Queue
elif sys.version_info >= (3,):
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/macpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

import os
import sys
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload

from _typeshed import AnyPath, BytesPath, StrPath
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload

if sys.version_info < (3, 8):
_T = TypeVar("_T")
Expand Down
4 changes: 1 addition & 3 deletions stdlib/2and3/mailbox.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import email
from _typeshed import AnyPath
from types import TracebackType
from typing import (
IO,
Expand All @@ -21,11 +22,8 @@ from typing import (
Union,
overload,
)

from typing_extensions import Literal

from _typeshed import AnyPath

_T = TypeVar("_T")
_MessageType = TypeVar("_MessageType", bound=Message)
_MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/mmap.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Optional, Sequence, Sized, Union, overload

from _typeshed import ReadableBuffer
from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Optional, Sequence, Sized, Union, overload

ACCESS_DEFAULT: int
ACCESS_READ: int
Expand Down
Loading