]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Disallow any Generics on mypy except in black_primer (#2556)
authorNipunn Koorapati <nipunn1313@gmail.com>
Fri, 22 Oct 2021 02:38:39 +0000 (19:38 -0700)
committerGitHub <noreply@github.com>
Fri, 22 Oct 2021 02:38:39 +0000 (19:38 -0700)
Only black_primer needs the disallowal - means we'll
get better typing everywhere else.

mypy.ini
src/black/__init__.py
src/black_primer/lib.py
tests/test_black.py
tests/test_primer.py

index 7e563e6f6963ea7699d4ecffb885c2c58d5655f2..dabef4583419ae34166d28f8ffd94382d19b1bbd 100644 (file)
--- a/mypy.ini
+++ b/mypy.ini
@@ -22,8 +22,7 @@ strict_optional=True
 warn_no_return=True
 warn_redundant_casts=True
 warn_unused_ignores=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.
 
 # 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-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.
 [mypy-black]
 # The following is because of `patch_click()`. Remove when
 # we drop Python 3.6 support.
index fdbaf040d642b0a41d15d0f98112090971425643..f01e449ea05b9d08afa5180bfa3b2b1daae6701a 100644 (file)
@@ -170,7 +170,7 @@ def validate_regex(
     ctx: click.Context,
     param: click.Parameter,
     value: Optional[str],
     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:
     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,
     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, ...],
     stdin_filename: Optional[str],
     workers: int,
     src: Tuple[str, ...],
index 7494ae6dc7dcbf8743bd5365bdbf819c5dfa45a5..c784279748541e84031e4b6061783f41cf1d9972 100644 (file)
@@ -258,7 +258,7 @@ async def git_checkout_or_rebase(
 
 
 def handle_PermissionError(
 
 
 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.
 ) -> None:
     """
     Handle PermissionError during shutil.rmtree.
index beb56cf1fdb24bde7256366f0aa1ebf7acb23f60..1fc63c942e9089aed7e34320d8f23a94910c5ba2 100644 (file)
@@ -2018,7 +2018,9 @@ with open(black.__file__, "r", encoding="utf-8") as _bf:
     black_source_lines = _bf.readlines()
 
 
     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.
     """Show function calls `from black/__init__.py` as they happen.
 
     Register this with `sys.settrace()` in a test you're debugging.
index e7f99fdb0c2ec97df80dce5fd4bd7bb129b5c175..dc30a7a224471de50a855318986bd4b93de3000d 100644 (file)
@@ -11,7 +11,7 @@ from pathlib import Path
 from platform import system
 from subprocess import CalledProcessError
 from tempfile import TemporaryDirectory, gettempdir
 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
 from unittest.mock import Mock, patch
 
 from click.testing import CliRunner
@@ -44,7 +44,9 @@ FAKE_PROJECT_CONFIG = {
 
 
 @contextmanager
 
 
 @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)
     old_stdout, sys.stdout = sys.stdout, StringIO()
     try:
         command(*args, **kwargs)