From d8e102886a60545d9e8f1c3ed9b566f7a2157bb9 Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Sun, 20 Oct 2024 10:55:13 +0200 Subject: [PATCH] test: add stubs for pyupgrade Can be removed if https://github.com/asottile/pyupgrade/issues/977 is resolved. --- mypy.ini | 5 ++--- pyproject.toml | 8 ++++++++ setup.cfg | 1 + stubs/pyupgrade/__init__.pyi | 0 stubs/pyupgrade/_data.pyi | 15 +++++++++++++++ stubs/pyupgrade/_main.pyi | 13 +++++++++++++ 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 stubs/pyupgrade/__init__.pyi create mode 100644 stubs/pyupgrade/_data.pyi create mode 100644 stubs/pyupgrade/_main.pyi diff --git a/mypy.ini b/mypy.ini index af0e1d623..5d0219f11 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,6 @@ [mypy] +mypy_path = stubs/ + disallow_any_unimported = True disallow_any_expr = False disallow_any_decorated = True @@ -81,9 +83,6 @@ ignore_missing_imports = True [mypy-pytest.*] ignore_missing_imports = True -[mypy-pyupgrade.*] -ignore_missing_imports = True - [mypy-setuptools.*] ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 05d3030fd..cfd2e65fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,10 +31,18 @@ revision = "origin/master..." revision = "origin/master..." src = ["."] +[tool.pylint.MASTER] +load-plugins = [ + "pylint_per_file_ignores", +] + [tool.pylint."messages control"] # Check import order only with isort. Pylint doesn't support a custom list of first # party packages. We want to consider "darkgraylib" and "graylint" as first party. disable = ["wrong-import-order"] +per-file-ignores = [ + "/stubs/:missing-class-docstring,missing-function-docstring,unused-argument", +] [tool.ruff] target-version = "py38" diff --git a/setup.cfg b/setup.cfg index 16dac6576..8c80b1836 100644 --- a/setup.cfg +++ b/setup.cfg @@ -75,6 +75,7 @@ test = pydocstyle pygments pylint<=3.2.7 # pylint 3.3.0 dropped Python 3.8 support + pylint-per-file-ignores pytest>=6.2.0 pytest-kwparametrize>=0.0.3 pyupgrade>=2.31.0 diff --git a/stubs/pyupgrade/__init__.pyi b/stubs/pyupgrade/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/pyupgrade/_data.pyi b/stubs/pyupgrade/_data.pyi new file mode 100644 index 000000000..c9837d99b --- /dev/null +++ b/stubs/pyupgrade/_data.pyi @@ -0,0 +1,15 @@ +"""Type stubs for bits used from `pyupgrade._data`. + +Can be removed if https://github.com/asottile/pyupgrade/issues/977 is resolved. + +""" + +from typing import NamedTuple + +Version = tuple[int, ...] + +class Settings(NamedTuple): + min_version: Version = ... + keep_percent_format: bool = ... + keep_mock: bool = ... + keep_runtime_typing: bool = ... diff --git a/stubs/pyupgrade/_main.pyi b/stubs/pyupgrade/_main.pyi new file mode 100644 index 000000000..e6b7734a9 --- /dev/null +++ b/stubs/pyupgrade/_main.pyi @@ -0,0 +1,13 @@ +"""Type stubs for bits used from `pyupgrade._main`. + +Can be removed if https://github.com/asottile/pyupgrade/issues/977 is resolved. + +""" + +from typing import Sequence + +from pyupgrade._data import Settings + +def _fix_plugins(contents_text: str, settings: Settings) -> str: ... +def _fix_tokens(contents_text: str) -> str: ... +def main(argv: Sequence[str] | None = None) -> int: ...