Skip to content

Commit

Permalink
Add type stub
Browse files Browse the repository at this point in the history
  • Loading branch information
romis2012 committed Feb 25, 2024
1 parent 9ae604a commit 4b9ba9e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pydantic_collections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'pydantic-collections'
__version__ = '0.5.2'
__version__ = '0.5.4'

from pydantic.version import VERSION as PYDANTIC_VERSION

Expand Down
28 changes: 28 additions & 0 deletions pydantic_collections/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
line-length = 99
target-version = ['py37', 'py38', 'py39']
skip-string-normalization = true
experimental-string-processing = true
preview = true
verbose = true

0 comments on commit 4b9ba9e

Please sign in to comment.