Skip to content

black: enable skip_magic_trailing_comma #5252

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

Merged
merged 3 commits into from
Apr 27, 2021
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: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
line_length = 130
target_version = ["py37"]
exclude = ".*_pb2.pyi"
skip_magic_trailing_comma = true

[tool.isort]
profile = "black"
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests-py3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# typeshed is released on PyPI.
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.4
black==21.4b0
black==21.4b1
flake8==3.8.4
flake8-bugbear==20.1.4
flake8-pyi==20.10.0
Expand Down
6 changes: 1 addition & 5 deletions stdlib/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,7 @@ def round(number: SupportsFloat) -> float: ...
def round(number: SupportsFloat, ndigits: int) -> float: ...
def setattr(__obj: Any, __name: Text, __value: Any) -> None: ...
def sorted(
__iterable: Iterable[_T],
*,
cmp: Callable[[_T, _T], int] = ...,
key: Optional[Callable[[_T], Any]] = ...,
reverse: bool = ...,
__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...
) -> List[_T]: ...
@overload
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...
Expand Down
6 changes: 1 addition & 5 deletions stdlib/@python2/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,7 @@ def round(number: SupportsFloat) -> float: ...
def round(number: SupportsFloat, ndigits: int) -> float: ...
def setattr(__obj: Any, __name: Text, __value: Any) -> None: ...
def sorted(
__iterable: Iterable[_T],
*,
cmp: Callable[[_T, _T], int] = ...,
key: Optional[Callable[[_T], Any]] = ...,
reverse: bool = ...,
__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...
) -> List[_T]: ...
@overload
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...
Expand Down
23 changes: 3 additions & 20 deletions stdlib/@python2/logging/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,13 @@ class Logger(Filterer):
) -> None: ...
fatal = critical
def log(
self,
level: int,
msg: Any,
*args: Any,
exc_info: _ExcInfoType = ...,
extra: Optional[Dict[str, Any]] = ...,
**kwargs: Any,
self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
) -> None: ...
def exception(
self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
) -> None: ...
def _log(
self,
level: int,
msg: Any,
args: _ArgsType,
exc_info: Optional[_ExcInfoType] = ...,
extra: Optional[Dict[str, Any]] = ...,
self, level: int, msg: Any, args: _ArgsType, exc_info: Optional[_ExcInfoType] = ..., extra: Optional[Dict[str, Any]] = ...
) -> None: ... # undocumented
def filter(self, record: LogRecord) -> bool: ...
def addHandler(self, hdlr: Handler) -> None: ...
Expand Down Expand Up @@ -210,13 +199,7 @@ class LoggerAdapter:
self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
) -> None: ...
def log(
self,
level: int,
msg: Any,
*args: Any,
exc_info: _ExcInfoType = ...,
extra: Optional[Dict[str, Any]] = ...,
**kwargs: Any,
self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
) -> None: ...
def isEnabledFor(self, level: int) -> bool: ...

Expand Down
12 changes: 1 addition & 11 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,7 @@ OpenTextModeUpdating = Literal[
"t+x",
"+tx",
]
OpenTextModeWriting = Literal[
"w",
"wt",
"tw",
"a",
"at",
"ta",
"x",
"xt",
"tx",
]
OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]
OpenBinaryModeUpdating = Literal[
Expand Down
6 changes: 1 addition & 5 deletions stdlib/asyncio/base_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class Server(AbstractServer):
ssl_handshake_timeout: Optional[float],
) -> None: ...
else:
def __init__(
self,
loop: AbstractEventLoop,
sockets: List[socket],
) -> None: ...
def __init__(self, loop: AbstractEventLoop, sockets: List[socket]) -> None: ...

class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def run_forever(self) -> None: ...
Expand Down
14 changes: 3 additions & 11 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,7 @@ class str(Sequence[str]):
def count(self, x: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ...
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
def endswith(
self,
__suffix: Union[str, Tuple[str, ...]],
__start: Optional[SupportsIndex] = ...,
__end: Optional[SupportsIndex] = ...,
self, __suffix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ...
Expand Down Expand Up @@ -375,10 +372,7 @@ class str(Sequence[str]):
def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(
self,
__prefix: Union[str, Tuple[str, ...]],
__start: Optional[SupportsIndex] = ...,
__end: Optional[SupportsIndex] = ...,
self, __prefix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...
) -> bool: ...
def strip(self, __chars: Optional[str] = ...) -> str: ...
def swapcase(self) -> str: ...
Expand Down Expand Up @@ -999,9 +993,7 @@ def eval(
__source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...
) -> Any: ...
def exec(
__source: Union[str, bytes, CodeType],
__globals: Optional[Dict[str, Any]] = ...,
__locals: Optional[Mapping[str, Any]] = ...,
__source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...
) -> Any: ...
def exit(code: object = ...) -> NoReturn: ...

Expand Down
12 changes: 2 additions & 10 deletions stdlib/distutils/filelist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ class FileList:
def process_template_line(self, line: str) -> None: ...
@overload
def include_pattern(
self,
pattern: str,
anchor: Union[int, bool] = ...,
prefix: Optional[str] = ...,
is_regex: Literal[0, False] = ...,
self, pattern: str, anchor: Union[int, bool] = ..., prefix: Optional[str] = ..., is_regex: Literal[0, False] = ...
) -> bool: ...
@overload
def include_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ...
Expand All @@ -34,11 +30,7 @@ class FileList:
) -> bool: ...
@overload
def exclude_pattern(
self,
pattern: str,
anchor: Union[int, bool] = ...,
prefix: Optional[str] = ...,
is_regex: Literal[0, False] = ...,
self, pattern: str, anchor: Union[int, bool] = ..., prefix: Optional[str] = ..., is_regex: Literal[0, False] = ...
) -> bool: ...
@overload
def exclude_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ...
Expand Down
6 changes: 1 addition & 5 deletions stdlib/ftplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,5 @@ def parse227(resp: str) -> Tuple[str, int]: ... # undocumented
def parse229(resp: str, peer: Any) -> Tuple[str, int]: ... # undocumented
def parse257(resp: str) -> str: ... # undocumented
def ftpcp(
source: FTP,
sourcename: str,
target: FTP,
targetname: str = ...,
type: Literal["A", "I"] = ...,
source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ...
) -> None: ... # undocumented
6 changes: 1 addition & 5 deletions stdlib/importlib/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ def source_from_cache(path: str) -> str: ...
def decode_source(source_bytes: bytes) -> str: ...
def find_spec(name: str, package: Optional[str] = ...) -> Optional[importlib.machinery.ModuleSpec]: ...
def spec_from_loader(
name: str,
loader: Optional[importlib.abc.Loader],
*,
origin: Optional[str] = ...,
is_package: Optional[bool] = ...,
name: str, loader: Optional[importlib.abc.Loader], *, origin: Optional[str] = ..., is_package: Optional[bool] = ...
) -> Optional[importlib.machinery.ModuleSpec]: ...
def spec_from_file_location(
name: str,
Expand Down
4 changes: 1 addition & 3 deletions stdlib/logging/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ else:

def dictConfig(config: dict[str, Any]) -> None: ...
def fileConfig(
fname: Union[_Path, IO[str], RawConfigParser],
defaults: Optional[dict[str, str]] = ...,
disable_existing_loggers: bool = ...,
fname: Union[_Path, IO[str], RawConfigParser], defaults: Optional[dict[str, str]] = ..., disable_existing_loggers: bool = ...
) -> None: ...
def listen(port: int = ..., verify: Optional[Callable[[bytes], Optional[bytes]]] = ...) -> Thread: ...
def stopListening() -> None: ...
12 changes: 2 additions & 10 deletions stdlib/smtpd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,10 @@ class DebuggingServer(SMTPServer): ...

class PureProxy(SMTPServer):
def process_message( # type: ignore
self,
peer: _Address,
mailfrom: str,
rcpttos: List[Text],
data: Union[bytes, str],
self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str]
) -> Optional[str]: ...

class MailmanProxy(PureProxy):
def process_message( # type: ignore
self,
peer: _Address,
mailfrom: str,
rcpttos: List[Text],
data: Union[bytes, str],
self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str]
) -> Optional[str]: ...
21 changes: 4 additions & 17 deletions stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,7 @@ class Misc:
# binds do. The default value of func is not str.
@overload
def bind(
self,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Misc]], Any]] = ...,
add: Optional[bool] = ...,
self, sequence: Optional[str] = ..., func: Optional[Callable[[Event[Misc]], Any]] = ..., add: Optional[bool] = ...
) -> str: ...
@overload
def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
Expand All @@ -361,10 +358,7 @@ class Misc:
# callbacks will get, so those are Misc.
@overload
def bind_all(
self,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Misc]], Any]] = ...,
add: Optional[bool] = ...,
self, sequence: Optional[str] = ..., func: Optional[Callable[[Event[Misc]], Any]] = ..., add: Optional[bool] = ...
) -> str: ...
@overload
def bind_all(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
Expand Down Expand Up @@ -840,10 +834,7 @@ class Widget(BaseWidget, Pack, Place, Grid):
# widgets don't.
@overload
def bind(
self: _W,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[_W]], Any]] = ...,
add: Optional[bool] = ...,
self: _W, sequence: Optional[str] = ..., func: Optional[Callable[[Event[_W]], Any]] = ..., add: Optional[bool] = ...
) -> str: ...
@overload
def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
Expand Down Expand Up @@ -2682,11 +2673,7 @@ class Text(Widget, XView, YView):
# tag_bind stuff is very similar to Canvas
@overload
def tag_bind(
self,
tagName: str,
sequence: Optional[str],
func: Optional[Callable[[Event[Text]], Any]],
add: Optional[bool] = ...,
self, tagName: str, sequence: Optional[str], func: Optional[Callable[[Event[Text]], Any]], add: Optional[bool] = ...
) -> str: ...
@overload
def tag_bind(self, tagName: str, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
Expand Down
5 changes: 1 addition & 4 deletions stdlib/tkinter/ttk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
# Also, it's 'callback' instead of 'func' here.
@overload
def tag_bind(
self,
tagname: str,
sequence: Optional[str] = ...,
callback: Optional[Callable[[tkinter.Event[Treeview]], Any]] = ...,
self, tagname: str, sequence: Optional[str] = ..., callback: Optional[Callable[[tkinter.Event[Treeview]], Any]] = ...
) -> str: ...
@overload
def tag_bind(self, tagname: str, sequence: Optional[str], callback: str) -> None: ...
Expand Down
11 changes: 2 additions & 9 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,7 @@ if sys.version_info >= (3, 7):
]
else:
_get_type_hints_obj_allowed_types = Union[
object,
Callable[..., Any],
FunctionType,
BuiltinFunctionType,
MethodType,
ModuleType,
object, Callable[..., Any], FunctionType, BuiltinFunctionType, MethodType, ModuleType,
]

if sys.version_info >= (3, 9):
Expand All @@ -621,9 +616,7 @@ if sys.version_info >= (3, 9):

else:
def get_type_hints(
obj: _get_type_hints_obj_allowed_types,
globalns: Optional[Dict[str, Any]] = ...,
localns: Optional[Dict[str, Any]] = ...,
obj: _get_type_hints_obj_allowed_types, globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ...
) -> Dict[str, Any]: ...

if sys.version_info >= (3, 8):
Expand Down
12 changes: 2 additions & 10 deletions stubs/JACK-Client/jack/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,7 @@ class Client:
can_monitor: bool = ...,
is_terminal: bool = ...,
) -> List[Port]: ...
def set_property(
self,
subject: Union[int, str],
key: str,
value: Union[str, bytes],
type: str = ...,
) -> None: ...
def set_property(self, subject: Union[int, str], key: str, value: Union[str, bytes], type: str = ...) -> None: ...
def remove_property(self, subject: Union[int, str], key: str) -> None: ...
def remove_properties(self, subject: Union[int, str]) -> int: ...
def remove_all_properties(self) -> None: ...
Expand Down Expand Up @@ -202,9 +196,7 @@ class OwnMidiPort(MidiPort, OwnPort):
def max_event_size(self) -> int: ...
@property
def lost_midi_events(self) -> int: ...
def incoming_midi_events(
self,
) -> Generator[Tuple[int, _CBufferType], None, None]: ...
def incoming_midi_events(self) -> Generator[Tuple[int, _CBufferType], None, None]: ...
def clear_buffer(self) -> None: ...
def write_midi_event(self, time: int, event: Union[bytes, Sequence[int], _CBufferType]) -> None: ...
def reserve_midi_event(self, time: int, size: int) -> _CBufferType: ...
Expand Down
13 changes: 2 additions & 11 deletions stubs/click-spinner/click_spinner/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,13 @@ class Spinner(object):
stream: _Stream
stop_running: Optional[threading.Event]
spin_thread: Optional[threading.Thread]
def __init__(
self,
beep: bool,
disable: bool,
force: bool,
stream: _Stream,
) -> None: ...
def __init__(self, beep: bool, disable: bool, force: bool, stream: _Stream) -> None: ...
def start(self) -> None: ...
def stop(self) -> None: ...
def init_spin(self) -> None: ...
def __enter__(self) -> Spinner: ...
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Literal[False]: ...

def spinner(beep: bool, disable: bool, force: bool, stream: _Stream) -> Spinner: ...
7 changes: 1 addition & 6 deletions stubs/click/click/formatting.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ class HelpFormatter:
def write(self, string: str) -> None: ...
def indent(self) -> None: ...
def dedent(self) -> None: ...
def write_usage(
self,
prog: str,
args: str = ...,
prefix: str = ...,
) -> None: ...
def write_usage(self, prog: str, args: str = ..., prefix: str = ...) -> None: ...
def write_heading(self, heading: str) -> None: ...
def write_paragraph(self) -> None: ...
def write_text(self, text: str) -> None: ...
Expand Down
6 changes: 1 addition & 5 deletions stubs/docopt/docopt.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ __version__: str
_Argv = Union[Iterable[str], str]

def docopt(
doc: str,
argv: Optional[_Argv] = ...,
help: bool = ...,
version: Optional[Any] = ...,
options_first: bool = ...,
doc: str, argv: Optional[_Argv] = ..., help: bool = ..., version: Optional[Any] = ..., options_first: bool = ...
) -> dict[str, Any]: ... # Really should be dict[str, Union[str, bool]]
Loading