Disallow any Generics on mypy except in black_primer (#2556)
Only black_primer needs the disallowal - means we'll get better typing everywhere else.
This commit is contained in:
parent
c75abed63e
commit
da8a5bb189
8
mypy.ini
8
mypy.ini
@ -22,8 +22,7 @@ strict_optional=True
|
||||
warn_no_return=True
|
||||
warn_redundant_casts=True
|
||||
warn_unused_ignores=True
|
||||
# Until we're not supporting 3.6 primer needs this
|
||||
disallow_any_generics=False
|
||||
disallow_any_generics=True
|
||||
|
||||
# The following are off by default. Flip them on if you feel
|
||||
# adventurous.
|
||||
@ -35,6 +34,11 @@ cache_dir=/dev/null
|
||||
|
||||
[mypy-aiohttp.*]
|
||||
follow_imports=skip
|
||||
|
||||
[mypy-black_primer.*]
|
||||
# Until we're not supporting 3.6 primer needs this
|
||||
disallow_any_generics=False
|
||||
|
||||
[mypy-black]
|
||||
# The following is because of `patch_click()`. Remove when
|
||||
# we drop Python 3.6 support.
|
||||
|
@ -170,7 +170,7 @@ def validate_regex(
|
||||
ctx: click.Context,
|
||||
param: click.Parameter,
|
||||
value: Optional[str],
|
||||
) -> Optional[Pattern]:
|
||||
) -> Optional[Pattern[str]]:
|
||||
try:
|
||||
return re_compile_maybe_verbose(value) if value is not None else None
|
||||
except re.error:
|
||||
@ -388,10 +388,10 @@ def main(
|
||||
quiet: bool,
|
||||
verbose: bool,
|
||||
required_version: str,
|
||||
include: Pattern,
|
||||
exclude: Optional[Pattern],
|
||||
extend_exclude: Optional[Pattern],
|
||||
force_exclude: Optional[Pattern],
|
||||
include: Pattern[str],
|
||||
exclude: Optional[Pattern[str]],
|
||||
extend_exclude: Optional[Pattern[str]],
|
||||
force_exclude: Optional[Pattern[str]],
|
||||
stdin_filename: Optional[str],
|
||||
workers: int,
|
||||
src: Tuple[str, ...],
|
||||
|
@ -258,7 +258,7 @@ async def git_checkout_or_rebase(
|
||||
|
||||
|
||||
def handle_PermissionError(
|
||||
func: Callable, path: Path, exc: Tuple[Any, Any, Any]
|
||||
func: Callable[..., None], path: Path, exc: Tuple[Any, Any, Any]
|
||||
) -> None:
|
||||
"""
|
||||
Handle PermissionError during shutil.rmtree.
|
||||
|
@ -2018,7 +2018,9 @@ def test_get_sources_with_stdin_filename_and_force_exclude(self) -> None:
|
||||
black_source_lines = _bf.readlines()
|
||||
|
||||
|
||||
def tracefunc(frame: types.FrameType, event: str, arg: Any) -> Callable:
|
||||
def tracefunc(
|
||||
frame: types.FrameType, event: str, arg: Any
|
||||
) -> Callable[[types.FrameType, str, Any], Any]:
|
||||
"""Show function calls `from black/__init__.py` as they happen.
|
||||
|
||||
Register this with `sys.settrace()` in a test you're debugging.
|
||||
|
@ -11,7 +11,7 @@
|
||||
from platform import system
|
||||
from subprocess import CalledProcessError
|
||||
from tempfile import TemporaryDirectory, gettempdir
|
||||
from typing import Any, Callable, Generator, Iterator, Tuple
|
||||
from typing import Any, Callable, Iterator, Tuple
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from click.testing import CliRunner
|
||||
@ -44,7 +44,9 @@
|
||||
|
||||
|
||||
@contextmanager
|
||||
def capture_stdout(command: Callable, *args: Any, **kwargs: Any) -> Generator:
|
||||
def capture_stdout(
|
||||
command: Callable[..., Any], *args: Any, **kwargs: Any
|
||||
) -> Iterator[str]:
|
||||
old_stdout, sys.stdout = sys.stdout, StringIO()
|
||||
try:
|
||||
command(*args, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user