Skip to content

Commit

Permalink
Update returned type from load and loads (#21)
Browse files Browse the repository at this point in the history
* Update returned type from load loads

Returned Dict[str, Any]

* shorter doc

To keep the linter rule line limit happy (<= 120 characters)

* Update README.md

Update the type returned by load and loads to Dict[str, Any]
  • Loading branch information
GilShoshan94 authored Apr 14, 2021
1 parent a7f9c22 commit 5a86f34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ If no binary is available on pypi for you system configuration; you'll need rust

#### load
```python
def load(toml: Union[str, Path, TextIO]) -> Any: ...
def load(toml: Union[str, Path, TextIO]) -> Dict[str, Any]: ...
```

Parse TOML via a string or file and return a python object. The `toml` argument may be a `str`,
Parse TOML via a string or file and return a python dictionary. The `toml` argument may be a `str`,
`Path` or file object from `open()`.

#### loads
```python
def loads(toml: str) -> Any: ...
def loads(toml: str) -> Dict[str, Any]: ...
```

Parse a TOML string and return a python object. (provided to match the interface of `json` and similar libraries)
Parse a TOML string and return a python dictionary. (provided to match the interface of `json` and similar libraries)

#### dumps
```python
Expand Down
10 changes: 5 additions & 5 deletions rtoml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import date, datetime, time, timezone
from io import TextIOBase
from pathlib import Path
from typing import Any, TextIO, Union
from typing import Any, Dict, TextIO, Union

from . import _rtoml

Expand All @@ -13,9 +13,9 @@
TomlSerializationError = _rtoml.TomlSerializationError


def load(toml: Union[str, Path, TextIO]) -> Any:
def load(toml: Union[str, Path, TextIO]) -> Dict[str, Any]:
"""
Parse TOML via a string or file and return a python object. The `toml` argument may be a `str`,
Parse TOML via a string or file and return a python dict. The `toml` argument may be a `str`,
`Path` or file object from `open()`.
"""
if isinstance(toml, Path):
Expand All @@ -26,9 +26,9 @@ def load(toml: Union[str, Path, TextIO]) -> Any:
return loads(toml)


def loads(toml: str) -> Any:
def loads(toml: str) -> Dict[str, Any]:
"""
Parse a TOML string and return a python object. (provided to match the interface of `json` and similar libraries)
Parse a TOML string and return a python dict. (provided to match the interface of `json` and similar libraries)
"""
if not isinstance(toml, str):
raise TypeError(f'invalid toml input, must be str not {type(toml)}')
Expand Down

0 comments on commit 5a86f34

Please sign in to comment.