Skip to content

Commit

Permalink
feat: added type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Sep 5, 2024
1 parent 7b15721 commit cce8f99
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

### Release 0.1.2 (unreleased)

- Added type annotations.

#### Testing

- Test under python 3.10, 3.11, and 3.12.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ prune .github
# these are redundant, as setuptools-scm includes everything in the git repo
include LICENSE.txt README.md CHANGES.md
include tox.ini
include src/unflatten.pyi src/py.typed
recursive-include tests *.py
Empty file added src/py.typed
Empty file.
16 changes: 16 additions & 0 deletions src/unflatten.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Mapping
from typing import overload
from typing import Sequence
from typing import TypeAlias
from typing import TypeVar

_T = TypeVar("_T")

Unflattened: TypeAlias = dict[
str, _T | "Unflattened[_T]" | list[_T | "Unflattened[_T]"]
]

@overload
def unflatten(arg: Mapping[str, _T]) -> Unflattened[_T]: ...
@overload
def unflatten(arg: Sequence[tuple[str, _T]]) -> Unflattened[_T]: ...

0 comments on commit cce8f99

Please sign in to comment.