Skip to content

Commit

Permalink
Add type definitions for item() (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Apr 16, 2022
1 parent 5118514 commit 352de24
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,10 @@

## [Unreleased]

- Fix the `astimezone()` and `replace()` methods of datetime objects. ([#188](https://github.com/sdispater/tomlkit/issues/178))
### Fixed

- Fix the `astimezone()` and `replace()` methods of datetime objects. ([#188](https://github.com/sdispater/tomlkit/issues/188))
- Add type definitions for `items()` function. ([#190](https://github.com/sdispater/tomlkit/issues/190))

## [0.10.1] - 2022-03-27

Expand Down
66 changes: 66 additions & 0 deletions tomlkit/items.py
Expand Up @@ -17,6 +17,7 @@
from typing import Iterator
from typing import List
from typing import Optional
from typing import Sequence
from typing import TypeVar
from typing import Union
from typing import cast
Expand Down Expand Up @@ -58,6 +59,71 @@ class _CustomDict(MutableMapping, dict):
"""Adds MutableMapping mixin while pretending to be a builtin dict"""


ItemT = TypeVar("ItemT", bound="Item")


@overload
def item(value: bool) -> "Bool":
...


@overload
def item(value: int) -> "Integer":
...


@overload
def item(value: float) -> "Float":
...


@overload
def item(value: str) -> "String":
...


@overload
def item(value: datetime) -> "DateTime":
...


@overload
def item(value: date) -> "Date":
...


@overload
def item(value: time) -> "Time":
...


@overload
def item(value: Sequence[dict]) -> "AoT":
...


@overload
def item(value: Sequence) -> "Array":
...


@overload
def item(value: dict, _parent: "Array" = ..., _sort_keys: bool = ...) -> "InlineTable":
...


@overload
def item(
value: dict, _parent: Optional["Item"] = ..., _sort_keys: bool = ...
) -> "Table":
...


@overload
def item(value: ItemT) -> ItemT:
...


def item(
value: Any, _parent: Optional["Item"] = None, _sort_keys: bool = False
) -> "Item":
Expand Down

0 comments on commit 352de24

Please sign in to comment.