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
4 changes: 4 additions & 0 deletions pyrsistent/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ T = TypeVar('T')
KT = TypeVar('KT')
VT = TypeVar('VT')

@overload
def pmap(initial: Mapping[KT, VT] = {}, pre_size: int = 0) -> PMap[KT, VT]: ...
@overload
def pmap(initial: Iterable[Tuple[KT, VT]] = {}, pre_size: int = 0) -> PMap[KT, VT]: ...
def pmap(initial: Union[Mapping[KT, VT], Iterable[Tuple[KT, VT]]] = {}, pre_size: int = 0) -> PMap[KT, VT]: ...
def m(**kwargs: VT) -> PMap[str, VT]: ...

Expand Down
6 changes: 6 additions & 0 deletions tests/typing_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Check that the inferred types are as expected.

from typing_extensions import assert_type
from pyrsistent import PMap, pmap

assert_type(pmap(dict[tuple[int, str], float]()), PMap[tuple[int, str], float])
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ commands = pytest
deps =
pytest
hypothesis
typing_extensions

# Specifying the following tests like this is very non-DRY but I have no better solution right now.
[testenv:coverage-py38]
Expand Down