From 4b9ba9e96fd66d32b21bf8cc88991ddec2e59e52 Mon Sep 17 00:00:00 2001 From: Roman Snegirev Date: Sun, 25 Feb 2024 11:56:20 +0300 Subject: [PATCH] Add type stub --- pydantic_collections/__init__.py | 2 +- pydantic_collections/__init__.pyi | 28 ++++++++++++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 pydantic_collections/__init__.pyi diff --git a/pydantic_collections/__init__.py b/pydantic_collections/__init__.py index 5699cc5..fffbc32 100644 --- a/pydantic_collections/__init__.py +++ b/pydantic_collections/__init__.py @@ -1,5 +1,5 @@ __title__ = 'pydantic-collections' -__version__ = '0.5.2' +__version__ = '0.5.4' from pydantic.version import VERSION as PYDANTIC_VERSION diff --git a/pydantic_collections/__init__.pyi b/pydantic_collections/__init__.pyi new file mode 100644 index 0000000..08cb813 --- /dev/null +++ b/pydantic_collections/__init__.pyi @@ -0,0 +1,28 @@ +from typing import TypeVar, MutableSequence, Optional, List, Union, overload, Any + +from pydantic import BaseModel, ConfigDict + +PYDANTIC_V2: bool +__version__: str + +class CollectionModelConfig(ConfigDict): + validate_assignment_strict: bool + +T = TypeVar('T') + +class BaseCollectionModel(MutableSequence[T], BaseModel): + def __init__(self, data: Optional[List[Union[T, dict]]] = None): ... + def insert(self, index: int, value: Union[T, dict]) -> None: ... + def append(self, value: Union[T, dict]) -> None: ... + def sort(self, key: Any, reverse: bool = False): ... + @overload + def __getitem__(self, index: int) -> T: ... + @overload + def __getitem__(self, index: slice) -> 'BaseCollectionModel[T]': ... + @overload + def __setitem__(self, index: int, value: Union[T, dict]) -> None: ... + @overload + def __delitem__(self, index: int) -> None: ... + @overload + def __delitem__(self, index: slice) -> None: ... + def __len__(self) -> int: ... diff --git a/pyproject.toml b/pyproject.toml index 55a2341..1dce759 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,5 +2,5 @@ line-length = 99 target-version = ['py37', 'py38', 'py39'] skip-string-normalization = true -experimental-string-processing = true +preview = true verbose = true