-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from gauravmm/feature-typeannotations
Added type annotations to pyi interface file.
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
recursive-include src/frozendict/c_src * | ||
include test/* | ||
include src/frozendict/py.typed | ||
include src/frozendict/frozendict.pyi | ||
include src/frozendict/__init__.pyi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from collections.abc import Hashable | ||
from typing import NoReturn, TypeVar, overload, Type, Optional | ||
|
||
try: | ||
from typing import Mapping, Sequence, Iterable, Iterator | ||
except ImportError: | ||
from collections.abc import Mapping, Sequence, Iterable, Iterator | ||
|
||
K = TypeVar("K") | ||
V = TypeVar("V") | ||
KV = TypeVar("KV", K, V) | ||
T = TypeVar("T", Mapping[K, V]) | ||
|
||
class frozendict(Mapping[K, V]): | ||
# Fake __init__ to describe what __new__ does: | ||
@overload | ||
def __init__(self, **kwargs: V) -> None: ... | ||
@overload | ||
def __init__(self, mapping: Mapping[K, V]) -> None: ... | ||
@overload | ||
def __init__(self, iterable: Iterable[Sequence[KV]]) -> None: ... | ||
|
||
# Magic Methods: | ||
def __getitem__(self, key: K) -> V: ... | ||
def __len__(self) -> int: ... | ||
def __iter__(self) -> Iterator[K]: ... | ||
def __hash__(self) -> int: ... | ||
def __repr__(self) -> str: ... | ||
def copy(self: T) -> T: ... | ||
def __copy__(self: T) -> T: ... | ||
def __deepcopy__(self: T) -> T: ... | ||
# Omit __reduce__, its used for Pickle and we don't need the annotation in code. | ||
def set(self: T, key: K, value: V) -> T: ... | ||
def setdefault(self: T, key: K, default: V) -> T: ... | ||
def delete(self: T, key: K) -> T: ... | ||
def key(self, index: int) -> K: ... | ||
def value(self, index: int) -> V: ... | ||
def item(self, index: int) -> Sequence[KV]: ... | ||
def __or__(self: T, other: Mapping[K, V]) -> T: ... | ||
def __reversed__(self) -> Iterator[K]: ... | ||
|
||
@classmethod | ||
def fromkeys( | ||
cls: Type[T], | ||
seq: Iterable[K], | ||
value: Optional[V] = None | ||
) -> "frozendict[K, V]": ... | ||
|
||
# Blacklisted methods: | ||
def __setattr__(self, *a, **kw) -> NoReturn: ... | ||
def __delattr__(self, *a, **kw) -> NoReturn: ... | ||
|
||
|
||
FrozenOrderedDict = frozendict |
This file was deleted.
Oops, something went wrong.