Skip to content

Commit

Permalink
Make first arg of load and loads positional only (#143)
Browse files Browse the repository at this point in the history
* Make first arg of `load` and `loads` positional only

* Changelog
  • Loading branch information
hukkin authored Nov 16, 2021
1 parent 9e56735 commit 374364a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Removed
- Python 3.6 support
- Support for text file objects as `load` input. Use binary file objects instead.
- First argument of `load` and `loads` can no longer be passed by keyword.
- Improved
- Raise an error when dotted keys define values outside the "current table".
Technically speaking TOML v1.0.0 does allow such assignments
Expand Down
8 changes: 4 additions & 4 deletions tomli/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ class TOMLDecodeError(ValueError):
"""An error raised if a document is not valid TOML."""


def load(fp: BinaryIO, *, parse_float: ParseFloat = float) -> dict[str, Any]:
def load(__fp: BinaryIO, *, parse_float: ParseFloat = float) -> dict[str, Any]:
"""Parse TOML from a binary file object."""
s = fp.read().decode()
s = __fp.read().decode()
return loads(s, parse_float=parse_float)


def loads(s: str, *, parse_float: ParseFloat = float) -> dict[str, Any]: # noqa: C901
def loads(__s: str, *, parse_float: ParseFloat = float) -> dict[str, Any]: # noqa: C901
"""Parse TOML from a string."""

# The spec allows converting "\r\n" to "\n", even in string
# literals. Let's do so to simplify parsing.
src = s.replace("\r\n", "\n")
src = __s.replace("\r\n", "\n")
pos = 0
out = Output(NestedDict(), Flags())
header: Key = ()
Expand Down

0 comments on commit 374364a

Please sign in to comment.