diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 85e4b067a..6a543d691 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -22,6 +22,7 @@ jobs: defusedxml \ pygments \ 'pylint<=3.2.7' \ + pylint-per-file-ignores \ pytest>=6.2.0 \ pyupgrade>=2.31.0 \ regex \ 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 1ffd0b406..a23d0bc4f 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: ...