From 7e4cd20bf4052e710b8c09b8d798803da6c11e49 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 31 Jan 2025 15:06:46 -0800 Subject: [PATCH 01/12] Adding stubs for pytest-snapshot --- .../pytest_snapshot/plugin.pyi | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 stubs/pytest-snapshot/pytest_snapshot/plugin.pyi diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi new file mode 100644 index 000000000000..71dd8c6ac491 --- /dev/null +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -0,0 +1,44 @@ +from pathlib import Path +from types import TracebackType +from typing import Any, Generator, Union + +import pytest + +@pytest.fixture +def snapshot(request: pytest.FixtureRequest) -> Generator[Snapshot, Any, None]: + ... + + +class Snapshot: + def __init__( + self, + snapshot_update: bool, + allow_snapshot_deletion: bool, + snapshot_dir: Path, + ): ... + def __enter__(self): ... + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: TracebackType | None, + ) -> None: ... + + @property + def snapshot_dir(self) -> Path: + ... + + @snapshot_dir.setter + def snapshot_dir(self, value: str | Path) -> None: ... + + def assert_match( + self, + value: Union[str, bytes], + snapshot_name: Union[str, Path], + ) -> None: ... + + def assert_match_dir( + self, + dir_dict: dict[Any, Any], + snapshot_dir_name: Union[str, Path], + ) -> None: ... From 8035df201e1adfb9d280df3efb9ee6b692bb2905 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:13:12 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks --- .../pytest_snapshot/plugin.pyi | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index 71dd8c6ac491..db71db092d2e 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -5,40 +5,17 @@ from typing import Any, Generator, Union import pytest @pytest.fixture -def snapshot(request: pytest.FixtureRequest) -> Generator[Snapshot, Any, None]: - ... - +def snapshot(request: pytest.FixtureRequest) -> Generator[Snapshot, Any, None]: ... class Snapshot: - def __init__( - self, - snapshot_update: bool, - allow_snapshot_deletion: bool, - snapshot_dir: Path, - ): ... + def __init__(self, snapshot_update: bool, allow_snapshot_deletion: bool, snapshot_dir: Path): ... def __enter__(self): ... def __exit__( - self, - exc_type: type[BaseException] | None, - exc_val: BaseException | None, - exc_tb: TracebackType | None, + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - @property - def snapshot_dir(self) -> Path: - ... - + def snapshot_dir(self) -> Path: ... @snapshot_dir.setter def snapshot_dir(self, value: str | Path) -> None: ... - - def assert_match( - self, - value: Union[str, bytes], - snapshot_name: Union[str, Path], - ) -> None: ... - - def assert_match_dir( - self, - dir_dict: dict[Any, Any], - snapshot_dir_name: Union[str, Path], - ) -> None: ... + def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path]) -> None: ... + def assert_match_dir(self, dir_dict: dict[Any, Any], snapshot_dir_name: Union[str, Path]) -> None: ... From bc4608ef09b49429099220ac0f36c16ae7b6b487 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 31 Jan 2025 15:24:06 -0800 Subject: [PATCH 03/12] CI suggestions --- pyrightconfig.stricter.json | 1 + stubs/pytest-snapshot/@tests/stubtest_allowlist.txt | 0 stubs/pytest-snapshot/METADATA.toml | 8 ++++++++ 3 files changed, 9 insertions(+) create mode 100644 stubs/pytest-snapshot/@tests/stubtest_allowlist.txt create mode 100644 stubs/pytest-snapshot/METADATA.toml diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index bc4da3eae855..2c23f1aa12f5 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -79,6 +79,7 @@ "stubs/pyflakes", "stubs/Pygments", "stubs/PyMySQL", + "stubs/pytest-snapshot", "stubs/python-crontab", "stubs/python-dateutil", "stubs/python-http-client", diff --git a/stubs/pytest-snapshot/@tests/stubtest_allowlist.txt b/stubs/pytest-snapshot/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pytest-snapshot/METADATA.toml b/stubs/pytest-snapshot/METADATA.toml new file mode 100644 index 000000000000..cb27ec3b790c --- /dev/null +++ b/stubs/pytest-snapshot/METADATA.toml @@ -0,0 +1,8 @@ +version = "0.9.*" +upstream_repository = "https://github.com/joseph-roitman/pytest-snapshot" +requires = [] +partial_stub = false + +[tool.stubtest] +stubtest_requirements = [] +ignore_missing_stub = true From 7ffdf2ac9f7ec4485ac8062f97b5b09cb619a5f7 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 31 Jan 2025 16:02:17 -0800 Subject: [PATCH 04/12] Union syntax --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index db71db092d2e..a702d58d0e2e 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -1,6 +1,6 @@ from pathlib import Path from types import TracebackType -from typing import Any, Generator, Union +from typing import Any, Generator import pytest @@ -17,5 +17,5 @@ class Snapshot: def snapshot_dir(self) -> Path: ... @snapshot_dir.setter def snapshot_dir(self, value: str | Path) -> None: ... - def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path]) -> None: ... - def assert_match_dir(self, dir_dict: dict[Any, Any], snapshot_dir_name: Union[str, Path]) -> None: ... + def assert_match(self, value: str | bytes, snapshot_name: str | Path) -> None: ... + def assert_match_dir(self, dir_dict: dict[Any, Any], snapshot_dir_name: str | Path) -> None: ... From 04bfad1b7e606466b2153fb26590a99199124746 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 31 Jan 2025 16:03:21 -0800 Subject: [PATCH 05/12] abc.Generator... --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index a702d58d0e2e..4101a37e9257 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -1,6 +1,7 @@ from pathlib import Path from types import TracebackType -from typing import Any, Generator +from typing import Any +from collections.abc import Generator import pytest From 5401a982fb0d0453791fc180f3a0980b70244b58 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 27 Feb 2025 09:52:55 -0800 Subject: [PATCH 06/12] Remove redundancy --- stubs/pytest-snapshot/METADATA.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/pytest-snapshot/METADATA.toml b/stubs/pytest-snapshot/METADATA.toml index cb27ec3b790c..15c308064be9 100644 --- a/stubs/pytest-snapshot/METADATA.toml +++ b/stubs/pytest-snapshot/METADATA.toml @@ -1,7 +1,6 @@ version = "0.9.*" upstream_repository = "https://github.com/joseph-roitman/pytest-snapshot" requires = [] -partial_stub = false [tool.stubtest] stubtest_requirements = [] From b609507b3f55ca206b05f339a2323589afd22d02 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 27 Feb 2025 09:53:23 -0800 Subject: [PATCH 07/12] Adding an __init__.pyi to remove the need for [tool.subtest] --- stubs/pytest-snapshot/METADATA.toml | 4 ---- stubs/pytest-snapshot/pytest_snapshot/__init__.pyi | 0 2 files changed, 4 deletions(-) create mode 100644 stubs/pytest-snapshot/pytest_snapshot/__init__.pyi diff --git a/stubs/pytest-snapshot/METADATA.toml b/stubs/pytest-snapshot/METADATA.toml index 15c308064be9..f5adde3de18e 100644 --- a/stubs/pytest-snapshot/METADATA.toml +++ b/stubs/pytest-snapshot/METADATA.toml @@ -1,7 +1,3 @@ version = "0.9.*" upstream_repository = "https://github.com/joseph-roitman/pytest-snapshot" requires = [] - -[tool.stubtest] -stubtest_requirements = [] -ignore_missing_stub = true diff --git a/stubs/pytest-snapshot/pytest_snapshot/__init__.pyi b/stubs/pytest-snapshot/pytest_snapshot/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 From 4c8393b81477019baa3f945ad5fda2a1af24b276 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:56:18 +0000 Subject: [PATCH 08/12] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index 4101a37e9257..55c43b3c9b43 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -1,7 +1,7 @@ +from collections.abc import Generator from pathlib import Path from types import TracebackType from typing import Any -from collections.abc import Generator import pytest From a23dbd110baea4d39e9d6db0480863e87e5bb600 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 27 Feb 2025 09:59:14 -0800 Subject: [PATCH 09/12] Adding pytest requirement --- stubs/pytest-snapshot/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pytest-snapshot/METADATA.toml b/stubs/pytest-snapshot/METADATA.toml index f5adde3de18e..85fadd4f26cd 100644 --- a/stubs/pytest-snapshot/METADATA.toml +++ b/stubs/pytest-snapshot/METADATA.toml @@ -1,3 +1,3 @@ version = "0.9.*" upstream_repository = "https://github.com/joseph-roitman/pytest-snapshot" -requires = [] +requires = ["pytest"] From 260951e74681e44548e74448c9194f3c36f65766 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 27 Feb 2025 10:07:52 -0800 Subject: [PATCH 10/12] Adding missing members --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index 55c43b3c9b43..4a515be04a98 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -2,9 +2,14 @@ from collections.abc import Generator from pathlib import Path from types import TracebackType from typing import Any +import re import pytest +import _pytest +PARAMETRIZED_TEST_REGEX: re.Pattern[str] + +def pytest_addoption(parser: _pytest.config.argparsing.Parser) -> None: ... @pytest.fixture def snapshot(request: pytest.FixtureRequest) -> Generator[Snapshot, Any, None]: ... From 62ae3938b0ef0ef057301429538d816c241bcdff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:11:10 +0000 Subject: [PATCH 11/12] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index 4a515be04a98..2e333124ad67 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -1,11 +1,11 @@ +import re from collections.abc import Generator from pathlib import Path from types import TracebackType from typing import Any -import re -import pytest import _pytest +import pytest PARAMETRIZED_TEST_REGEX: re.Pattern[str] From 9cf47ad9d8eb36a4d33fa5e542a6da6e772977e9 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 27 Feb 2025 10:13:05 -0800 Subject: [PATCH 12/12] Trying again --- stubs/pytest-snapshot/pytest_snapshot/plugin.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi index 2e333124ad67..e139fad029fe 100644 --- a/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi +++ b/stubs/pytest-snapshot/pytest_snapshot/plugin.pyi @@ -4,7 +4,7 @@ from pathlib import Path from types import TracebackType from typing import Any -import _pytest +import _pytest.config.argparsing import pytest PARAMETRIZED_TEST_REGEX: re.Pattern[str]