diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index cac67e234..14973d1be 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -30,6 +30,7 @@ "stdlib/xml/sax", "stubs/aiofiles/aiofiles/tempfile/temptypes.pyi", "stubs/antlr4-python3-runtime", + "stubs/assertpy", "stubs/aws-xray-sdk", "stubs/beautifulsoup4", "stubs/bleach/bleach/sanitizer.pyi", diff --git a/stubs/assertpy/@tests/stubtest_allowlist.txt b/stubs/assertpy/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..2de67f358 --- /dev/null +++ b/stubs/assertpy/@tests/stubtest_allowlist.txt @@ -0,0 +1,11 @@ +assertpy.collection.Iterable +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 diff --git a/stubs/assertpy/METADATA.toml b/stubs/assertpy/METADATA.toml new file mode 100644 index 000000000..548b8958c --- /dev/null +++ b/stubs/assertpy/METADATA.toml @@ -0,0 +1,2 @@ +version = "1.1.*" +upstream_repository = "https://github.com/assertpy/assertpy" diff --git a/stubs/assertpy/assertpy/__init__.pyi b/stubs/assertpy/assertpy/__init__.pyi new file mode 100644 index 000000000..1eba206f8 --- /dev/null +++ b/stubs/assertpy/assertpy/__init__.pyi @@ -0,0 +1,12 @@ +from .assertpy import ( + WarningLoggingAdapter as WarningLoggingAdapter, + __version__ as __version__, + add_extension as add_extension, + assert_that as assert_that, + assert_warn as assert_warn, + fail as fail, + remove_extension as remove_extension, + soft_assertions as soft_assertions, + soft_fail as soft_fail, +) +from .file import contents_of as contents_of diff --git a/stubs/assertpy/assertpy/assertpy.pyi b/stubs/assertpy/assertpy/assertpy.pyi new file mode 100644 index 000000000..3000dfd1e --- /dev/null +++ b/stubs/assertpy/assertpy/assertpy.pyi @@ -0,0 +1,70 @@ +import logging +from collections.abc import Callable, Generator +from typing import Any +from typing_extensions import Self + +from .base import BaseMixin +from .collection import CollectionMixin +from .contains import ContainsMixin +from .date import DateMixin +from .dict import DictMixin +from .dynamic import DynamicMixin +from .exception import ExceptionMixin +from .extracting import ExtractingMixin +from .file import FileMixin +from .helpers import HelpersMixin +from .numeric import NumericMixin +from .snapshot import SnapshotMixin +from .string import StringMixin + +__version__: str +__tracebackhide__: bool + +class WarningLoggingAdapter(logging.LoggerAdapter[logging.Logger]): + def process(self, msg: str, kwargs: Any) -> tuple[str, Any]: ... + +class AssertionBuilder( + StringMixin, + SnapshotMixin, + NumericMixin, + HelpersMixin, + FileMixin, + ExtractingMixin, + ExceptionMixin, + DynamicMixin, + DictMixin, + DateMixin, + ContainsMixin, + CollectionMixin, + BaseMixin, +): + val: Any + description: str + kind: str | None + expected: BaseException | None + logger: logging.Logger + def __init__( + self, + val: Any, + description: str = "", + kind: str | None = None, + expected: BaseException | None = None, + logger: logging.Logger | None = None, + ) -> None: ... + def builder( + self, + val: Any, + 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 fail(msg: str = "") -> None: ... +def soft_fail(msg: str = "") -> None: ... +def add_extension(func: Callable[[AssertionBuilder], AssertionBuilder]) -> None: ... +def remove_extension(func: Callable[[AssertionBuilder], AssertionBuilder]) -> None: ... diff --git a/stubs/assertpy/assertpy/base.pyi b/stubs/assertpy/assertpy/base.pyi new file mode 100644 index 000000000..8181d33de --- /dev/null +++ b/stubs/assertpy/assertpy/base.pyi @@ -0,0 +1,21 @@ +from typing import Any +from typing_extensions import Self, TypeAlias + +__tracebackhide__: bool + +_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_true(self) -> Self: ... + def is_false(self) -> Self: ... + def is_none(self) -> Self: ... + def is_not_none(self) -> Self: ... + def is_type_of(self, some_type: type) -> Self: ... + def is_instance_of(self, some_class: type) -> Self: ... + def is_length(self, length: int) -> Self: ... diff --git a/stubs/assertpy/assertpy/collection.pyi b/stubs/assertpy/assertpy/collection.pyi new file mode 100644 index 000000000..68485dbef --- /dev/null +++ b/stubs/assertpy/assertpy/collection.pyi @@ -0,0 +1,11 @@ +from collections.abc import Callable +from typing import Any +from typing_extensions import Self + +__tracebackhide__: bool + +class CollectionMixin: + 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: ... diff --git a/stubs/assertpy/assertpy/contains.pyi b/stubs/assertpy/assertpy/contains.pyi new file mode 100644 index 000000000..2953e40c9 --- /dev/null +++ b/stubs/assertpy/assertpy/contains.pyi @@ -0,0 +1,16 @@ +from typing import Any +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: ... + 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: ... diff --git a/stubs/assertpy/assertpy/date.pyi b/stubs/assertpy/assertpy/date.pyi new file mode 100644 index 000000000..5377724ef --- /dev/null +++ b/stubs/assertpy/assertpy/date.pyi @@ -0,0 +1,11 @@ +from datetime import date +from typing_extensions import Self + +__tracebackhide__: bool + +class DateMixin: + def is_before(self, other: date) -> Self: ... + def is_after(self, other: date) -> Self: ... + def is_equal_to_ignoring_milliseconds(self, other: date) -> Self: ... + def is_equal_to_ignoring_seconds(self, other: date) -> Self: ... + def is_equal_to_ignoring_time(self, other: date) -> Self: ... diff --git a/stubs/assertpy/assertpy/dict.pyi b/stubs/assertpy/assertpy/dict.pyi new file mode 100644 index 000000000..f88e86db7 --- /dev/null +++ b/stubs/assertpy/assertpy/dict.pyi @@ -0,0 +1,12 @@ +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: ... diff --git a/stubs/assertpy/assertpy/dynamic.pyi b/stubs/assertpy/assertpy/dynamic.pyi new file mode 100644 index 000000000..52c8c24d0 --- /dev/null +++ b/stubs/assertpy/assertpy/dynamic.pyi @@ -0,0 +1,7 @@ +from collections.abc import Callable +from typing_extensions import Self + +__tracebackhide__: bool + +class DynamicMixin: + def __getattr__(self, attr: str) -> Callable[..., Self]: ... diff --git a/stubs/assertpy/assertpy/exception.pyi b/stubs/assertpy/assertpy/exception.pyi new file mode 100644 index 000000000..2af5e46ba --- /dev/null +++ b/stubs/assertpy/assertpy/exception.pyi @@ -0,0 +1,8 @@ +from typing import Any +from typing_extensions import Self + +__tracebackhide__: bool + +class ExceptionMixin: + def raises(self, ex: type[BaseException] | BaseException) -> Self: ... + def when_called_with(self, *some_args: Any, **some_kwargs: dict[str, Any]) -> Self: ... diff --git a/stubs/assertpy/assertpy/extracting.pyi b/stubs/assertpy/assertpy/extracting.pyi new file mode 100644 index 000000000..c8de113d3 --- /dev/null +++ b/stubs/assertpy/assertpy/extracting.pyi @@ -0,0 +1,7 @@ +from typing import Any +from typing_extensions import Self + +__tracebackhide__: bool + +class ExtractingMixin: + def extracting(self, *names: Any, **kwargs: dict[str, Any]) -> Self: ... diff --git a/stubs/assertpy/assertpy/file.pyi b/stubs/assertpy/assertpy/file.pyi new file mode 100644 index 000000000..1bff54a1a --- /dev/null +++ b/stubs/assertpy/assertpy/file.pyi @@ -0,0 +1,15 @@ +from _typeshed import StrPath +from typing import IO, AnyStr +from typing_extensions import Self + +__tracebackhide__: bool + +def contents_of(file: IO[AnyStr] | StrPath, encoding: str = "utf-8") -> str: ... + +class FileMixin: + def exists(self) -> Self: ... + def does_not_exist(self) -> Self: ... + def is_file(self) -> Self: ... + def is_directory(self) -> Self: ... + def is_named(self, filename: str) -> Self: ... + def is_child_of(self, parent: str) -> Self: ... diff --git a/stubs/assertpy/assertpy/helpers.pyi b/stubs/assertpy/assertpy/helpers.pyi new file mode 100644 index 000000000..3ef068fa3 --- /dev/null +++ b/stubs/assertpy/assertpy/helpers.pyi @@ -0,0 +1,3 @@ +__tracebackhide__: bool + +class HelpersMixin: ... diff --git a/stubs/assertpy/assertpy/numeric.pyi b/stubs/assertpy/assertpy/numeric.pyi new file mode 100644 index 000000000..725bc4ed4 --- /dev/null +++ b/stubs/assertpy/assertpy/numeric.pyi @@ -0,0 +1,24 @@ +from datetime import date +from typing_extensions import Self, TypeAlias + +__tracebackhide__: bool + +_Numeric: TypeAlias = date | int | float + +class NumericMixin: + def is_zero(self) -> Self: ... + def is_not_zero(self) -> Self: ... + def is_nan(self) -> Self: ... + def is_not_nan(self) -> Self: ... + def is_inf(self) -> Self: ... + def is_not_inf(self) -> Self: ... + def is_greater_than(self, other: _Numeric) -> Self: ... + def is_greater_than_or_equal_to(self, other: _Numeric) -> Self: ... + def is_less_than(self, other: _Numeric) -> Self: ... + def is_less_than_or_equal_to(self, other: _Numeric) -> Self: ... + def is_positive(self) -> Self: ... + def is_negative(self) -> Self: ... + def is_between(self, low: _Numeric, high: _Numeric) -> Self: ... + def is_not_between(self, low: _Numeric, high: _Numeric) -> Self: ... + def is_close_to(self, other: _Numeric, tolerance: _Numeric) -> Self: ... + def is_not_close_to(self, other: _Numeric, tolerance: _Numeric) -> Self: ... diff --git a/stubs/assertpy/assertpy/snapshot.pyi b/stubs/assertpy/assertpy/snapshot.pyi new file mode 100644 index 000000000..2a7abc9fe --- /dev/null +++ b/stubs/assertpy/assertpy/snapshot.pyi @@ -0,0 +1,6 @@ +from typing_extensions import Self + +__tracebackhide__: bool + +class SnapshotMixin: + def snapshot(self, id: str | None = None, path: str = "__snapshots") -> Self: ... diff --git a/stubs/assertpy/assertpy/string.pyi b/stubs/assertpy/assertpy/string.pyi new file mode 100644 index 000000000..c7e978309 --- /dev/null +++ b/stubs/assertpy/assertpy/string.pyi @@ -0,0 +1,18 @@ +from re import Pattern +from typing_extensions import Self + +unicode = str +__tracebackhide__: bool + +class StringMixin: + def is_equal_to_ignoring_case(self, other: str) -> Self: ... + def contains_ignoring_case(self, *items: str) -> Self: ... + def starts_with(self, prefix: str) -> Self: ... + def ends_with(self, suffix: str) -> Self: ... + def matches(self, pattern: Pattern[str]) -> Self: ... + def does_not_match(self, pattern: Pattern[str]) -> Self: ... + def is_alpha(self) -> Self: ... + def is_digit(self) -> Self: ... + def is_lower(self) -> Self: ... + def is_upper(self) -> Self: ... + def is_unicode(self) -> Self: ...