Migrate mypy config to pyproject.toml (#3936)
Co-authored-by: Charles Patel <charles.patel@apkudo.com>
This commit is contained in:
parent
3bb92146f5
commit
6f84f65285
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@
|
|||||||
_build
|
_build
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
|
.python-version
|
||||||
docs/_static/pypi.svg
|
docs/_static/pypi.svg
|
||||||
.tox
|
.tox
|
||||||
__pycache__
|
__pycache__
|
||||||
|
@ -43,6 +43,7 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
exclude: ^docs/conf.py
|
exclude: ^docs/conf.py
|
||||||
|
args: ["--config-file", "pyproject.toml"]
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- types-PyYAML
|
- types-PyYAML
|
||||||
- tomli >= 0.2.6, < 2.0.0
|
- tomli >= 0.2.6, < 2.0.0
|
||||||
@ -51,6 +52,10 @@ repos:
|
|||||||
- platformdirs >= 2.1.0
|
- platformdirs >= 2.1.0
|
||||||
- pytest
|
- pytest
|
||||||
- hypothesis
|
- hypothesis
|
||||||
|
- aiohttp >= 3.7.4
|
||||||
|
- types-commonmark
|
||||||
|
- urllib3
|
||||||
|
- hypothesmith
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
rev: v3.0.3
|
rev: v3.0.3
|
||||||
|
46
mypy.ini
46
mypy.ini
@ -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
|
|
@ -137,6 +137,7 @@ exclude = [
|
|||||||
# Compiled modules can't be run directly and that's a problem here:
|
# Compiled modules can't be run directly and that's a problem here:
|
||||||
"/src/black/__main__.py",
|
"/src/black/__main__.py",
|
||||||
]
|
]
|
||||||
|
mypy-args = ["--ignore-missing-imports"]
|
||||||
options = { debug_level = "0" }
|
options = { debug_level = "0" }
|
||||||
|
|
||||||
[tool.cibuildwheel]
|
[tool.cibuildwheel]
|
||||||
@ -223,3 +224,26 @@ omit = [
|
|||||||
]
|
]
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
relative_files = true
|
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
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import commonmark
|
import commonmark
|
||||||
import yaml
|
import yaml
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup # type: ignore[import]
|
||||||
|
|
||||||
|
|
||||||
def main(changes: str, source_version_control: str) -> None:
|
def main(changes: str, source_version_control: str) -> None:
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import commonmark
|
import commonmark
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup # type: ignore[import]
|
||||||
|
|
||||||
|
|
||||||
def main(changes: str, the_basics: str) -> None:
|
def main(changes: str, the_basics: str) -> None:
|
||||||
|
@ -119,7 +119,7 @@ def main() -> None:
|
|||||||
@main.command("config", help="Acquire run configuration and metadata.")
|
@main.command("config", help="Acquire run configuration and metadata.")
|
||||||
@click.argument("event", type=click.Choice(["push", "pull_request"]))
|
@click.argument("event", type=click.Choice(["push", "pull_request"]))
|
||||||
def config(event: Literal["push", "pull_request"]) -> None:
|
def config(event: Literal["push", "pull_request"]) -> None:
|
||||||
import diff_shades
|
import diff_shades # type: ignore[import]
|
||||||
|
|
||||||
if event == "push":
|
if event == "push":
|
||||||
jobs = [{"mode": "preview-changes", "force-flag": "--force-preview-style"}]
|
jobs = [{"mode": "preview-changes", "force-flag": "--force-preview-style"}]
|
||||||
|
@ -80,7 +80,7 @@ def test_idempotent_any_syntatically_valid_python(
|
|||||||
try:
|
try:
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import atheris
|
import atheris # type: ignore[import]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
from os.path import basename, dirname, join
|
from os.path import basename, dirname, join
|
||||||
from typing import Iterable, Tuple
|
from typing import Iterable, Tuple
|
||||||
|
|
||||||
import wcwidth
|
import wcwidth # type: ignore[import]
|
||||||
|
|
||||||
|
|
||||||
def make_width_table() -> Iterable[Tuple[int, int, int]]:
|
def make_width_table() -> Iterable[Tuple[int, int, int]]:
|
||||||
|
@ -74,7 +74,9 @@ def main(bind_host: str, bind_port: int) -> None:
|
|||||||
app = make_app()
|
app = make_app()
|
||||||
ver = black.__version__
|
ver = black.__version__
|
||||||
black.out(f"blackd version {ver} listening on {bind_host} port {bind_port}")
|
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:
|
def make_app() -> web.Application:
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
from pytest import StashKey
|
from pytest import StashKey
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# pytest < 7
|
# 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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ def unittest_run_loop(func, *args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.blackd
|
@pytest.mark.blackd
|
||||||
class BlackDTestCase(AioHTTPTestCase): # type: ignore[misc]
|
class BlackDTestCase(AioHTTPTestCase):
|
||||||
def test_blackd_main(self) -> None:
|
def test_blackd_main(self) -> None:
|
||||||
with patch("blackd.web.run_app"):
|
with patch("blackd.web.run_app"):
|
||||||
result = CliRunner().invoke(blackd.main, [])
|
result = CliRunner().invoke(blackd.main, [])
|
||||||
|
Loading…
Reference in New Issue
Block a user