Skip to content

Commit

Permalink
Preparations for the Big Reformat
Browse files Browse the repository at this point in the history
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @Overloads at the top of the file needed to be moved
due to psf/black#1490.
  • Loading branch information
srittau committed Jun 14, 2020
1 parent 53431ca commit 2bfaf19
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 46 deletions.
4 changes: 1 addition & 3 deletions stdlib/2and3/contextlib.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Stubs for contextlib

# ContextManager aliased here for backwards compatibility; TODO eventually remove this
from typing import (
Any, Callable, Generator, IO, Iterable, Iterator, Optional, Type,
Generic, TypeVar, overload
)
from types import TracebackType
import sys
# Aliased here for backwards compatibility; TODO eventually remove this
from typing import ContextManager as ContextManager

if sys.version_info >= (3, 5):
Expand Down
4 changes: 0 additions & 4 deletions stdlib/2and3/shutil.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import os
import sys

# 'bytes' paths are not properly supported: they don't work with all functions,
# sometimes they only work partially (broken exception messages), and the test
# cases don't use them.

from typing import (
List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple,
AnyStr, Optional, Union, Set, TypeVar, overload, Type, Protocol, Text
Expand Down
4 changes: 1 addition & 3 deletions stdlib/2and3/sysconfig.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Stubs for sysconfig

from typing import overload, Any, Dict, IO, List, Optional, Tuple, Union

def get_config_var(name: str) -> Optional[str]: ...
@overload
def get_config_vars() -> Dict[str, Any]: ...
@overload
def get_config_vars(arg: str, *args: str) -> List[Any]: ...
def get_config_var(name: str) -> Optional[str]: ...
def get_scheme_names() -> Tuple[str, ...]: ...
def get_path_names() -> Tuple[str, ...]: ...
def get_path(name: str, scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> Optional[str]: ...
Expand Down
9 changes: 5 additions & 4 deletions stdlib/3/ast.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import sys
# Rename typing to _typing, as not to conflict with typing imported
# from _ast below when loaded in an unorthodox way by the Dropbox
# internal Bazel integration.
import typing as _typing
from typing import Any, Iterator, Optional, TypeVar, Union, overload
from typing_extensions import Literal

# The same unorthodox Bazel integration causes issues with sys, which
# is imported in both modules. unfortunately we can't just rename sys,
# since mypy only supports version checks with a sys that is named
# sys.
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

if sys.version_info >= (3, 8):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/3/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ from asyncio.protocols import BaseProtocol
from asyncio.tasks import Task
from asyncio.transports import BaseTransport
from asyncio.unix_events import AbstractChildWatcher
from _typeshed import FileDescriptorLike

if sys.version_info >= (3, 7):
from contextvars import Context

from _typeshed import FileDescriptorLike

_T = TypeVar('_T')
_Context = Dict[str, Any]
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
Expand Down
2 changes: 0 additions & 2 deletions stdlib/3/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ from typing import (
)
from _typeshed import AnyPath

# Re-exported names from other modules.
from builtins import OSError as error
from . import path as path

# We need to use something from path, or flake8 and pytype get unhappy
_supports_unicode_filenames = path.supports_unicode_filenames

_T = TypeVar("_T")
Expand Down
3 changes: 0 additions & 3 deletions third_party/2/six/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Stubs for six (Python 2.7)

from __future__ import print_function

import types
Expand All @@ -10,7 +8,6 @@ from typing import (
import typing
import unittest

# Exports
from __builtin__ import unichr as unichr
from StringIO import StringIO as StringIO, StringIO as BytesIO
from functools import wraps as wraps
Expand Down
3 changes: 1 addition & 2 deletions third_party/2and3/bleach/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Container, Iterable, Optional, Text

from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker
from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
from bleach.sanitizer import (
ALLOWED_ATTRIBUTES as ALLOWED_ATTRIBUTES,
ALLOWED_PROTOCOLS as ALLOWED_PROTOCOLS,
Expand All @@ -9,7 +9,6 @@ from bleach.sanitizer import (
Cleaner as Cleaner,
)

from .linkifier import _Callback

__releasedate__: Text
__version__: Text
Expand Down
2 changes: 1 addition & 1 deletion third_party/2and3/bleach/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from collections import OrderedDict
from typing import overload, Mapping, Any, Text

def force_unicode(text: Text) -> Text: ...
@overload
def alphabetize_attributes(attrs: None) -> None: ...
@overload
def alphabetize_attributes(attrs: Mapping[Any, Text]) -> OrderedDict[Any, Text]: ...
def force_unicode(text: Text) -> Text: ...
5 changes: 3 additions & 2 deletions third_party/2and3/boto/compat.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import sys

from typing import Any

from six.moves import http_client

if sys.version_info >= (3,):
from base64 import encodebytes as encodebytes
else:
from base64 import encodestring as encodebytes

from six.moves import http_client

expanduser: Any

if sys.version_info >= (3, 0):
Expand Down
17 changes: 0 additions & 17 deletions third_party/2and3/click/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
:license: BSD, see LICENSE for more details.
"""

# Core classes
from .core import (
Context as Context,
BaseCommand as BaseCommand,
Expand All @@ -26,11 +25,7 @@ from .core import (
Option as Option,
Argument as Argument,
)

# Globals
from .globals import get_current_context as get_current_context

# Decorators
from .decorators import (
pass_context as pass_context,
pass_obj as pass_obj,
Expand All @@ -44,8 +39,6 @@ from .decorators import (
version_option as version_option,
help_option as help_option,
)

# Types
from .types import (
ParamType as ParamType,
File as File,
Expand All @@ -62,8 +55,6 @@ from .types import (
UUID as UUID,
UNPROCESSED as UNPROCESSED,
)

# Utilities
from .utils import (
echo as echo,
get_binary_stream as get_binary_stream,
Expand All @@ -73,8 +64,6 @@ from .utils import (
get_app_dir as get_app_dir,
get_os_args as get_os_args,
)

# Terminal functions
from .termui import (
prompt as prompt,
confirm as confirm,
Expand All @@ -90,8 +79,6 @@ from .termui import (
getchar as getchar,
pause as pause,
)

# Exceptions
from .exceptions import (
ClickException as ClickException,
UsageError as UsageError,
Expand All @@ -103,11 +90,7 @@ from .exceptions import (
BadArgumentUsage as BadArgumentUsage,
MissingParameter as MissingParameter,
)

# Formatting
from .formatting import HelpFormatter as HelpFormatter, wrap_text as wrap_text

# Parsing
from .parser import OptionParser as OptionParser

# Controls if click should emit the warning about the use of unicode
Expand Down
3 changes: 0 additions & 3 deletions third_party/3/six/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Stubs for six (Python 3.5)

from __future__ import print_function

from typing import (
Expand All @@ -26,7 +24,6 @@ import types
import typing
import unittest

# Exports
from io import StringIO as StringIO, BytesIO as BytesIO
from builtins import next as next
from functools import wraps as wraps
Expand Down

0 comments on commit 2bfaf19

Please sign in to comment.