Skip to content

Commit

Permalink
test: add stubs for pyupgrade
Browse files Browse the repository at this point in the history
Can be removed if asottile/pyupgrade#977 is
resolved.
  • Loading branch information
akaihola committed Dec 31, 2024
1 parent bdba037 commit 0412519
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[mypy]
mypy_path = stubs/

disallow_any_unimported = True
disallow_any_expr = False
disallow_any_decorated = True
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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
Expand Down
Empty file added stubs/pyupgrade/__init__.pyi
Empty file.
15 changes: 15 additions & 0 deletions stubs/pyupgrade/_data.pyi
Original file line number Diff line number Diff line change
@@ -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 = ...
13 changes: 13 additions & 0 deletions stubs/pyupgrade/_main.pyi
Original file line number Diff line number Diff line change
@@ -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: ...

0 comments on commit 0412519

Please sign in to comment.