Skip to content
Merged
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
7 changes: 1 addition & 6 deletions stubs/assertpy/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Python 2 compatibility cruft:
assertpy.collection.Iterable
assertpy\..+\.Iterable(\.__class_getitem__)?
assertpy.contains.str_types
assertpy.contains.xrange
assertpy.dynamic.Iterable
assertpy.exception.Iterable
assertpy.extracting.Iterable
assertpy.extracting.str_types
assertpy.file.str_types
assertpy.helpers.Iterable
assertpy.string.Iterable
assertpy.string.str_types
23 changes: 13 additions & 10 deletions stubs/assertpy/assertpy/assertpy.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from collections.abc import Callable, Generator
from typing import Any
from typing import Any, TypeVar
from typing_extensions import Self

from .base import BaseMixin
Expand All @@ -17,11 +17,14 @@ from .numeric import NumericMixin
from .snapshot import SnapshotMixin
from .string import StringMixin

_T = TypeVar("_T")
_V = TypeVar("_V", default=Any)

__version__: str
__tracebackhide__: bool

class WarningLoggingAdapter(logging.LoggerAdapter[logging.Logger]):
def process(self, msg: str, kwargs: Any) -> tuple[str, Any]: ...
def process(self, msg: str, kwargs: _T) -> tuple[str, _T]: ...

class AssertionBuilder(
StringMixin,
Expand All @@ -34,36 +37,36 @@ class AssertionBuilder(
DynamicMixin,
DictMixin,
DateMixin,
ContainsMixin,
CollectionMixin,
ContainsMixin[_V],
CollectionMixin[_V],
BaseMixin,
):
val: Any
val: _V
description: str
kind: str | None
expected: BaseException | None
logger: logging.Logger
def __init__(
self,
val: Any,
val: _V,
description: str = "",
kind: str | None = None,
expected: BaseException | None = None,
logger: logging.Logger | None = None,
) -> None: ...
def builder(
self,
val: Any,
val: _V,
description: str = "",
kind: str | None = None,
expected: BaseException | None = None,
logger: logging.Logger | None = None,
) -> Self: ...
def error(self, msg: str) -> Self: ...

def soft_assertions() -> Generator[None, None, None]: ...
def assert_that(val: Any, description: str = "") -> AssertionBuilder: ...
def assert_warn(val: Any, description: str = "", logger: logging.Logger | None = None) -> AssertionBuilder: ...
def soft_assertions() -> Generator[None]: ...
def assert_that(val: _V, description: str = "") -> AssertionBuilder[_V]: ...
def assert_warn(val: _V, description: str = "", logger: logging.Logger | None = None) -> AssertionBuilder: ...
def fail(msg: str = "") -> None: ...
def soft_fail(msg: str = "") -> None: ...
def add_extension(func: Callable[[AssertionBuilder], AssertionBuilder]) -> None: ...
Expand Down
9 changes: 4 additions & 5 deletions stubs/assertpy/assertpy/base.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Any
from typing_extensions import Self, TypeAlias

__tracebackhide__: bool
Expand All @@ -8,10 +7,10 @@ _IncludeIgnore: TypeAlias = str | list[str] | list[tuple[str, ...]] | None
class BaseMixin:
description: str
def described_as(self, description: str) -> Self: ...
def is_equal_to(self, other: Any, *, include: _IncludeIgnore = None, ignore: _IncludeIgnore = None) -> Self: ...
def is_not_equal_to(self, other: Any) -> Self: ...
def is_same_as(self, other: Any) -> Self: ...
def is_not_same_as(self, other: Any) -> Self: ...
def is_equal_to(self, other: object, *, include: _IncludeIgnore = None, ignore: _IncludeIgnore = None) -> Self: ...
def is_not_equal_to(self, other: object) -> Self: ...
def is_same_as(self, other: object) -> Self: ...
def is_not_same_as(self, other: object) -> Self: ...
def is_true(self) -> Self: ...
def is_false(self) -> Self: ...
def is_none(self) -> Self: ...
Expand Down
16 changes: 12 additions & 4 deletions stubs/assertpy/assertpy/collection.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from _typeshed import SupportsRichComparison
from collections.abc import Callable
from typing import Any
from typing import Any, Generic, Literal, TypeVar, overload
from typing_extensions import Self

__tracebackhide__: bool

class CollectionMixin:
_V = TypeVar("_V", default=Any)

class CollectionMixin(Generic[_V]):
def is_iterable(self) -> Self: ...
def is_not_iterable(self) -> Self: ...
def is_subset_of(self, *supersets: Any) -> Self: ...
def is_sorted(self, key: Callable[[Any], Any] = ..., reverse: bool = False) -> Self: ...
def is_subset_of(self, *supersets: _V) -> Self: ...
@overload
def is_sorted(self, key: Callable[[_V], SupportsRichComparison] = ..., reverse: Literal[False] = False) -> Self: ...
@overload
def is_sorted(self, *, reverse: Literal[True]) -> Self: ...
@overload
def is_sorted(self, key: Callable[[_V], SupportsRichComparison], reverse: Literal[True]) -> Self: ...
18 changes: 10 additions & 8 deletions stubs/assertpy/assertpy/contains.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from typing import Any
from typing import Any, Generic, TypeVar
from typing_extensions import Self

__tracebackhide__: bool

class ContainsMixin:
def contains(self, *items: Any) -> Self: ...
def does_not_contain(self, *items: Any) -> Self: ...
def contains_only(self, *items: Any) -> Self: ...
def contains_sequence(self, *items: Any) -> Self: ...
_V = TypeVar("_V", default=Any)

class ContainsMixin(Generic[_V]):
def contains(self, *items: object) -> Self: ...
def does_not_contain(self, *items: object) -> Self: ...
def contains_only(self, *items: object) -> Self: ...
def contains_sequence(self, *items: object) -> Self: ...
def contains_duplicates(self) -> Self: ...
def does_not_contain_duplicates(self) -> Self: ...
def is_empty(self) -> Self: ...
def is_not_empty(self) -> Self: ...
def is_in(self, *items: Any) -> Self: ...
def is_not_in(self, *items: Any) -> Self: ...
def is_in(self, *items: _V) -> Self: ...
def is_not_in(self, *items: _V) -> Self: ...
14 changes: 8 additions & 6 deletions stubs/assertpy/assertpy/dict.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from collections.abc import Iterable
from typing import Any
from typing_extensions import Self

__tracebackhide__: bool

class DictMixin:
def contains_key(self, *keys: Any) -> Self: ...
def does_not_contain_key(self, *keys: Any) -> Self: ...
def contains_value(self, *values: Any) -> Self: ...
def does_not_contain_value(self, *values: Any) -> Self: ...
def contains_entry(self, *args: Any, **kwargs: dict[str, Any]) -> Self: ...
def does_not_contain_entry(self, *args: Any, **kwargs: dict[str, Any]) -> Self: ...
def contains_key(self, *keys: object) -> Self: ...
def does_not_contain_key(self, *keys: object) -> Self: ...
def contains_value(self, *values: object) -> Self: ...
def does_not_contain_value(self, *values: object) -> Self: ...
# The dicts can contain arbitrary keys and values
def contains_entry(self, *args: Iterable[dict[Any, Any]], **kwargs: Any) -> Self: ...
def does_not_contain_entry(self, *args: Iterable[dict[Any, Any]], **kwargs: Any) -> Self: ...
2 changes: 1 addition & 1 deletion stubs/assertpy/assertpy/dynamic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ from typing_extensions import Self
__tracebackhide__: bool

class DynamicMixin:
def __getattr__(self, attr: str) -> Callable[..., Self]: ...
def __getattr__(self, attr: str) -> Callable[[object], Self]: ...
6 changes: 4 additions & 2 deletions stubs/assertpy/assertpy/extracting.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Callable, Iterable as _Iterable, Mapping
from _typeshed import SupportsRichComparison
from collections.abc import Callable, Iterable, Mapping
from typing import Any
from typing_extensions import Self

Expand All @@ -8,6 +9,7 @@ class ExtractingMixin:
def extracting(
self,
*names: str,
# The callable must accept the type of the items in the self.val collection.
filter: str | Mapping[str, Any] | Callable[[Any], bool] = ...,
sort: str | _Iterable[str] | Callable[[Any], Any] = ...,
sort: str | Iterable[str] | Callable[[Any], SupportsRichComparison] = ...,
) -> Self: ...
5 changes: 2 additions & 3 deletions stubs/assertpy/assertpy/file.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from _typeshed import StrPath
from typing import IO, AnyStr
from _typeshed import StrPath, SupportsRead
from typing_extensions import Self

__tracebackhide__: bool

def contents_of(file: IO[AnyStr] | StrPath, encoding: str = "utf-8") -> str: ...
def contents_of(file: SupportsRead[str] | StrPath, encoding: str = "utf-8") -> str: ...

class FileMixin:
def exists(self) -> Self: ...
Expand Down