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

Upgrade to isort 5 #4323

Merged
merged 6 commits into from
Jul 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
script: black --check --diff stdlib third_party
- name: "isort"
install: pip install $(grep isort requirements-tests-py3.txt)
script: isort --check-only --diff --recursive stdlib third_party
script: isort --check-only --diff stdlib third_party
35 changes: 33 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,38 @@ multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
combine_as_imports = true
line_length = 130
default_section = "THIRDPARTY"
known_standard_library = ["typing_extensions", "_typeshed", "_compression", "_markupbase", "opcode"]
extra_standard_library = [
"typing_extensions",
"_typeshed",
# Extra modules not recognized by isort
"_compression",
"_csv",
"_curses",
"_markupbase",
"_random",
"_weakrefset",
"genericpath",
"opcode",
"pyexpat",
# Python 2 modules
"__builtin__",
"cookielib",
"cStringIO",
"httplib",
"mimetools",
"rfc822",
"thread",
"urllib2",
"urlparse",
"BaseHTTPServer",
"Queue",
"SimpleHTTPServer",
"SocketServer",
"StringIO",
"UserDict",
"UserList",
"UserString",
]
4 changes: 2 additions & 2 deletions requirements-tests-py3.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.4
black==19.10b0
flake8==3.8.2
flake8==3.8.3
flake8-bugbear==20.1.4
flake8-pyi==20.5.0
isort[pyproject]==4.3.21
isort[pyproject]==5.1.1
pytype>=2020.06.26
2 changes: 1 addition & 1 deletion stdlib/2and3/_dummy_threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Event:
def wait(self, timeout: Optional[float] = ...) -> bool: ...

if sys.version_info >= (3, 8):
from _thread import _ExceptHookArgs as ExceptHookArgs, ExceptHookArgs as _ExceptHookArgs # don't ask
from _thread import ExceptHookArgs as _ExceptHookArgs, _ExceptHookArgs as ExceptHookArgs # don't ask
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm impressed


excepthook: Callable[[_ExceptHookArgs], Any]

Expand Down
2 changes: 1 addition & 1 deletion stdlib/2and3/logging/handlers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from socket import SocketType
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload

if sys.version_info >= (3, 7):
from queue import SimpleQueue, Queue
from queue import Queue, SimpleQueue
elif sys.version_info >= (3,):
from queue import Queue
else:
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2and3/threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Event:
def wait(self, timeout: Optional[float] = ...) -> bool: ...

if sys.version_info >= (3, 8):
from _thread import _ExceptHookArgs as ExceptHookArgs, ExceptHookArgs as _ExceptHookArgs # don't ask
from _thread import ExceptHookArgs as _ExceptHookArgs, _ExceptHookArgs as ExceptHookArgs # don't ask

excepthook: Callable[[_ExceptHookArgs], Any]

Expand Down
2 changes: 1 addition & 1 deletion stdlib/2and3/wsgiref/simple_server.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment
if sys.version_info < (3,):
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
else:
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer

server_version: str # undocumented
sys_version: str # undocumented
Expand Down
19 changes: 5 additions & 14 deletions stdlib/3/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,10 @@ else:
from asyncio.events import SendfileNotAvailableError as SendfileNotAvailableError
from asyncio.futures import (
CancelledError as CancelledError,
TimeoutError as TimeoutError,
InvalidStateError as InvalidStateError,
TimeoutError as TimeoutError,
)
from asyncio.streams import (
IncompleteReadError as IncompleteReadError,
LimitOverrunError as LimitOverrunError,
)
from asyncio.streams import IncompleteReadError as IncompleteReadError, LimitOverrunError as LimitOverrunError

if sys.version_info >= (3, 7):
from asyncio.protocols import BufferedProtocol as BufferedProtocol
Expand All @@ -104,11 +101,7 @@ if sys.version_info >= (3, 7):
from asyncio.runners import run as run

if sys.version_info >= (3, 7):
from asyncio.tasks import (
all_tasks as all_tasks,
create_task as create_task,
current_task as current_task,
)
from asyncio.tasks import all_tasks as all_tasks, create_task as create_task, current_task as current_task
if sys.version_info >= (3, 9):
from asyncio.threads import to_thread as to_thread

Expand All @@ -117,10 +110,8 @@ if sys.platform == "win32":
from asyncio.windows_events import *

if sys.platform != "win32":
from asyncio.streams import (
open_unix_connection as open_unix_connection,
start_unix_server as start_unix_server,
)
from asyncio.streams import open_unix_connection as open_unix_connection, start_unix_server as start_unix_server

from .unix_events import (
AbstractChildWatcher as AbstractChildWatcher,
FastChildWatcher as FastChildWatcher,
Expand Down
3 changes: 1 addition & 2 deletions stdlib/3/asyncio/futures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional
from .events import AbstractEventLoop

if sys.version_info < (3, 8):
from concurrent.futures import CancelledError as CancelledError
from concurrent.futures import TimeoutError as TimeoutError
from concurrent.futures import CancelledError as CancelledError, TimeoutError as TimeoutError
class InvalidStateError(Error): ...

if sys.version_info >= (3, 7):
Expand Down
5 changes: 1 addition & 4 deletions stdlib/3/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ from typing import (
from . import abc

if sys.version_info >= (3, 6):
from typing import (
Collection as Collection,
AsyncGenerator as AsyncGenerator,
)
from typing import AsyncGenerator as AsyncGenerator, Collection as Collection

_S = TypeVar("_S")
_T = TypeVar("_T")
Expand Down
6 changes: 1 addition & 5 deletions stdlib/3/collections/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@ from . import (
)

if sys.version_info >= (3, 6):
from . import (
Collection as Collection,
Reversible as Reversible,
AsyncGenerator as AsyncGenerator,
)
from . import AsyncGenerator as AsyncGenerator, Collection as Collection, Reversible as Reversible
3 changes: 1 addition & 2 deletions stdlib/3/importlib/resources.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import sys
# This is a >=3.7 module, so we conditionally include its source.
if sys.version_info >= (3, 7):
import os

from pathlib import Path
from types import ModuleType
from typing import ContextManager, Iterator, Union, BinaryIO, TextIO
from typing import BinaryIO, ContextManager, Iterator, TextIO, Union

Package = Union[str, ModuleType]
Resource = Union[str, os.PathLike]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/multiprocessing/managers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ from typing import (
from .context import BaseContext

if sys.version_info >= (3, 8):
from .shared_memory import ShareableList, SharedMemory, _SLT
from .shared_memory import _SLT, ShareableList, SharedMemory

_T = TypeVar("_T")
_KT = TypeVar("_KT")
Expand Down
4 changes: 2 additions & 2 deletions stdlib/3/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union

# ----- re variables and constants -----
if sys.version_info >= (3, 7):
from typing import Pattern as Pattern, Match as Match
from typing import Match as Match, Pattern as Pattern
else:
from typing import Pattern, Match
from typing import Match, Pattern

if sys.version_info >= (3, 6):
import enum
Expand Down
3 changes: 1 addition & 2 deletions third_party/2and3/decorator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ _T = TypeVar("_T")
def get_init(cls): ...

if sys.version_info >= (3,):
from inspect import iscoroutinefunction as iscoroutinefunction
from inspect import getfullargspec as getfullargspec
from inspect import getfullargspec as getfullargspec, iscoroutinefunction as iscoroutinefunction
else:
class FullArgSpec(NamedTuple):
args: List[str]
Expand Down
2 changes: 1 addition & 1 deletion third_party/2and3/jinja2/environment.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from .loaders import BaseLoader
from .runtime import Context, Undefined

if sys.version_info >= (3, 6):
from typing import Awaitable, AsyncIterator
from typing import AsyncIterator, Awaitable

def get_spontaneous_environment(*args): ...
def create_cache(size): ...
Expand Down
6 changes: 2 additions & 4 deletions third_party/2and3/requests/packages/urllib3/connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ from .packages import ssl_match_hostname
from .util import ssl_

if sys.version_info < (3, 0):
from httplib import HTTPConnection as _HTTPConnection
from httplib import HTTPException as HTTPException
from httplib import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
class ConnectionError(Exception): ...

else:
from http.client import HTTPConnection as _HTTPConnection
from http.client import HTTPException as HTTPException
from builtins import ConnectionError as ConnectionError
from http.client import HTTPConnection as _HTTPConnection, HTTPException as HTTPException

class DummyConnection: ...

Expand Down
12 changes: 7 additions & 5 deletions third_party/2and3/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ if sys.version_info >= (3, 3):
from typing import ChainMap as ChainMap

if sys.version_info >= (3, 5):
from typing import AsyncIterable as AsyncIterable
from typing import AsyncIterator as AsyncIterator
from typing import AsyncContextManager as AsyncContextManager
from typing import Awaitable as Awaitable
from typing import Coroutine as Coroutine
from typing import (
AsyncContextManager as AsyncContextManager,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
Coroutine as Coroutine,
)

if sys.version_info >= (3, 6):
from typing import AsyncGenerator as AsyncGenerator
Expand Down
4 changes: 2 additions & 2 deletions third_party/2and3/werkzeug/serving.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import sys
from typing import Any, Optional

if sys.version_info < (3,):
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
else:
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ThreadingMixIn
from http.server import HTTPServer, BaseHTTPRequestHandler

if sys.platform == "win32":
class ForkingMixIn(object): ...
Expand Down
4 changes: 2 additions & 2 deletions third_party/2and3/werkzeug/test.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ from typing import Any, Generic, Optional, Text, Tuple, Type, TypeVar, overload
from typing_extensions import Literal

if sys.version_info < (3,):
from urllib2 import Request as U2Request
from cookielib import CookieJar
from urllib2 import Request as U2Request
else:
from urllib.request import Request as U2Request
from http.cookiejar import CookieJar
from urllib.request import Request as U2Request

def stream_encode_multipart(
values, use_tempfile: int = ..., threshold=..., boundary: Optional[Any] = ..., charset: Text = ...
Expand Down