Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"stubs/pyflakes",
"stubs/Pygments",
"stubs/PyMySQL",
"stubs/pytest-snapshot",
"stubs/python-crontab",
"stubs/python-dateutil",
"stubs/python-http-client",
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions stubs/pytest-snapshot/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "0.9.*"
upstream_repository = "https://github.com/joseph-roitman/pytest-snapshot"
requires = ["pytest"]
Empty file.
27 changes: 27 additions & 0 deletions stubs/pytest-snapshot/pytest_snapshot/plugin.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import re
from collections.abc import Generator
from pathlib import Path
from types import TracebackType
from typing import Any

import _pytest.config.argparsing
import pytest

PARAMETRIZED_TEST_REGEX: re.Pattern[str]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
PARAMETRIZED_TEST_REGEX: re.Pattern[str]
PARAMETRIZED_TEST_REGEX: Final[re.Pattern[str]]

Final needs to be imported from typing.


def pytest_addoption(parser: _pytest.config.argparsing.Parser) -> None: ...
@pytest.fixture
def snapshot(request: pytest.FixtureRequest) -> Generator[Snapshot, Any, None]: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use Generator[Snapshot] (although many annotations haven't been updated since type var defaults have been introduced), which is equivalent to Generator[Snapshot, None, None]. If it's important to you that anything can be sent into the generator, use object instead of Any, which we used for ignored parameters.


class Snapshot:
def __init__(self, snapshot_update: bool, allow_snapshot_deletion: bool, snapshot_dir: Path): ...
def __enter__(self): ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __enter__(self): ...
def __enter__(self) -> Self: ...

(Self needs to be imported from typing_extensions.)

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: str | bytes, snapshot_name: str | Path) -> None: ...
def assert_match_dir(self, dir_dict: dict[Any, Any], snapshot_dir_name: str | Path) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now require each use of Any to be documented with the accepted types/usage. If you are unsure what the correct types are, you can use Incomplete (from _typeshed) – which is an alias of Any – instead.