Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make first arg of load and loads positional only #143

Merged
merged 2 commits into from Nov 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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