]> 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:

Migrate mypy config to pyproject.toml (#3936)
authorCharles Patel <17268094+acharles7@users.noreply.github.com>
Mon, 16 Oct 2023 12:24:16 +0000 (07:24 -0500)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 12:24:16 +0000 (05:24 -0700)
Co-authored-by: Charles Patel <charles.patel@apkudo.com>
12 files changed:
.gitignore
.pre-commit-config.yaml
mypy.ini [deleted file]
pyproject.toml
scripts/check_pre_commit_rev_in_example.py
scripts/check_version_in_basics_example.py
scripts/diff_shades_gha_helper.py
scripts/fuzz.py
scripts/make_width_table.py
src/blackd/__init__.py
tests/optional.py
tests/test_blackd.py

index 249499b135e38ec95f0e7e9454672ad08daeed31..4a4f1b738ad12d59e0eb37475abc05c3673b9a0e 100644 (file)
@@ -4,6 +4,7 @@
 _build
 .DS_Store
 .vscode
+.python-version
 docs/_static/pypi.svg
 .tox
 __pycache__
index 99b3565ed0ecb15b75f9b0335c8b6b1e8bb312b3..623e661ac0747bdcfaba1709524c5e6a82925a13 100644 (file)
@@ -43,6 +43,7 @@ repos:
     hooks:
       - id: mypy
         exclude: ^docs/conf.py
+        args: ["--config-file", "pyproject.toml"]
         additional_dependencies:
           - types-PyYAML
           - tomli >= 0.2.6, < 2.0.0
@@ -51,6 +52,10 @@ repos:
           - platformdirs >= 2.1.0
           - pytest
           - hypothesis
+          - aiohttp >= 3.7.4
+          - types-commonmark
+          - urllib3
+          - hypothesmith
 
   - repo: https://github.com/pre-commit/mirrors-prettier
     rev: v3.0.3
diff --git a/mypy.ini b/mypy.ini
deleted file mode 100644 (file)
index ad91618..0000000
--- a/mypy.ini
+++ /dev/null
@@ -1,46 +0,0 @@
-[mypy]
-# Specify the target platform details in config, so your developers are
-# free to run mypy on Windows, Linux, or macOS and get consistent
-# results.
-python_version=3.8
-
-mypy_path=src
-
-show_column_numbers=True
-show_error_codes=True
-
-# be strict
-strict=True
-
-# except for...
-no_implicit_reexport = False
-
-# Unreachable blocks have been an issue when compiling mypyc, let's try
-# to avoid 'em in the first place.
-warn_unreachable=True
-
-[mypy-blib2to3.driver.*]
-ignore_missing_imports = True
-
-[mypy-IPython.*]
-ignore_missing_imports = True
-
-[mypy-colorama.*]
-ignore_missing_imports = True
-
-[mypy-pathspec.*]
-ignore_missing_imports = True
-
-[mypy-tokenize_rt.*]
-ignore_missing_imports = True
-
-[mypy-uvloop.*]
-ignore_missing_imports = True
-
-[mypy-_black_version.*]
-ignore_missing_imports = True
-
-# CI only checks src/, but in case users are running LSP or similar we explicitly ignore
-# errors in test data files.
-[mypy-tests.data.*]
-ignore_errors = True
index d246eb0b272e32e9687b2f54e61e481ea9fe86c9..8c55076e4c9331048f196affa4f40957d547663a 100644 (file)
@@ -137,6 +137,7 @@ exclude = [
   # Compiled modules can't be run directly and that's a problem here:
   "/src/black/__main__.py",
 ]
+mypy-args = ["--ignore-missing-imports"]
 options = { debug_level = "0" }
 
 [tool.cibuildwheel]
@@ -223,3 +224,26 @@ omit = [
 ]
 [tool.coverage.run]
 relative_files = true
+
+[tool.mypy]
+# Specify the target platform details in config, so your developers are
+# free to run mypy on Windows, Linux, or macOS and get consistent
+# results.
+python_version = "3.8"
+mypy_path = "src"
+strict = true
+# Unreachable blocks have been an issue when compiling mypyc, let's try to avoid 'em in the first place.
+warn_unreachable = true
+implicit_reexport = true
+show_error_codes = true
+show_column_numbers = true
+
+[[tool.mypy.overrides]]
+module = ["pathspec.*", "IPython.*", "colorama.*", "tokenize_rt.*", "uvloop.*", "_black_version.*"]
+ignore_missing_imports = true
+
+# CI only checks src/, but in case users are running LSP or similar we explicitly ignore
+# errors in test data files.
+[[tool.mypy.overrides]]
+module = ["tests.data.*"]
+ignore_errors = true
index 9560b3b840100b5de0507fc17f872c010bfc0666..107c6444dca348d368dc8ab35895fa14600e7490 100644 (file)
@@ -14,7 +14,7 @@ import sys
 
 import commonmark
 import yaml
-from bs4 import BeautifulSoup
+from bs4 import BeautifulSoup  # type: ignore[import]
 
 
 def main(changes: str, source_version_control: str) -> None:
index 7f559b3aee1401621f2f906e07089d5d458585b1..0f42bafe334e5198235530c193c09fa7d75d8302 100644 (file)
@@ -8,7 +8,7 @@ import os
 import sys
 
 import commonmark
-from bs4 import BeautifulSoup
+from bs4 import BeautifulSoup  # type: ignore[import]
 
 
 def main(changes: str, the_basics: str) -> None:
index 7a58fbe9b2809a616c97ad594e2c678edf8b29fc..895516deb51b03ca708c097dc7979e449eeca07a 100644 (file)
@@ -119,7 +119,7 @@ def main() -> None:
 @main.command("config", help="Acquire run configuration and metadata.")
 @click.argument("event", type=click.Choice(["push", "pull_request"]))
 def config(event: Literal["push", "pull_request"]) -> None:
-    import diff_shades
+    import diff_shades  # type: ignore[import]
 
     if event == "push":
         jobs = [{"mode": "preview-changes", "force-flag": "--force-preview-style"}]
index 0c507381d9265492e745877214478f84912ef36c..929d3eac4f57132dfb5c3e5364109a30052cbfa4 100644 (file)
@@ -80,7 +80,7 @@ if __name__ == "__main__":
     try:
         import sys
 
-        import atheris
+        import atheris  # type: ignore[import]
     except ImportError:
         pass
     else:
index 061fdc8d95da77d16fbc1617e84a1ccf370fb229..3c7cae60f7fbffd2a309fba37894eaeb0474607d 100644 (file)
@@ -20,7 +20,7 @@ import sys
 from os.path import basename, dirname, join
 from typing import Iterable, Tuple
 
-import wcwidth
+import wcwidth  # type: ignore[import]
 
 
 def make_width_table() -> Iterable[Tuple[int, int, int]]:
index 6b0f3d33295163a2810676d773ed2ee35691be3f..972f24181cb60e538e5237ea9597c9315758dc21 100644 (file)
@@ -74,7 +74,9 @@ def main(bind_host: str, bind_port: int) -> None:
     app = make_app()
     ver = black.__version__
     black.out(f"blackd version {ver} listening on {bind_host} port {bind_port}")
-    web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None)
+    # TODO: aiohttp had an incorrect annotation for `print` argument,
+    #  It'll be fixed once aiohttp releases that code
+    web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None)  # type: ignore[arg-type]
 
 
 def make_app() -> web.Application:
index 8a39cc440a6cdf7aa602704b8124c18c97f32edb..3f5277b6b034c0b513b9cbd146cdc796680a95c0 100644 (file)
@@ -26,7 +26,7 @@ try:
     from pytest import StashKey
 except ImportError:
     # pytest < 7
-    from _pytest.store import StoreKey as StashKey  # type: ignore[no-redef]
+    from _pytest.store import StoreKey as StashKey  # type: ignore[import, no-redef]
 
 log = logging.getLogger(__name__)
 
index c0152de73e6a83e587cbe28001b27f438daaa041..59703036dc07dfd7a41a804a60f4762124b77ed1 100644 (file)
@@ -31,7 +31,7 @@ else:
 
 
 @pytest.mark.blackd
-class BlackDTestCase(AioHTTPTestCase):  # type: ignore[misc]
+class BlackDTestCase(AioHTTPTestCase):
     def test_blackd_main(self) -> None:
         with patch("blackd.web.run_app"):
             result = CliRunner().invoke(blackd.main, [])