Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into drop-py36
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Oct 25, 2021
2 parents 8b804d3 + c151139 commit 5be5bfd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Expand Up @@ -2,7 +2,7 @@
commit = True
tag = True
tag_name = {new_version}
current_version = 1.2.1
current_version = 1.2.2

[bumpversion:file:pyproject.toml]
search = version = "{current_version}" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Report coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v2

test-built-package:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,8 +2,16 @@

## **unreleased**

- no changes yet

## 1.2.2

- Fixed
- Illegal characters in error messages were surrounded by two pairs of quotation marks
- Improved
- `TOMLDecodeError.__module__` is now the public import path (`tomli`) instead of private import path (`tomli._parser`)
- Eliminated an import cycle when `typing.TYPE_CHECKING` is `True`.
This allows `sphinx-autodoc-typehints` to resolve type annotations.

## 1.2.1

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "tomli"
version = "1.2.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
version = "1.2.2" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
description = "A lil' TOML parser"
authors = [
{ name = "Taneli Hukkinen", email = "hukkin@users.noreply.github.com" },
Expand Down
4 changes: 4 additions & 0 deletions tests/test_error.py
Expand Up @@ -31,3 +31,7 @@ def test_invalid_char_quotes():
with pytest.raises(tomli.TOMLDecodeError) as exc_info:
tomli.loads("v = '\n'")
assert " '\\n' " in str(exc_info.value)


def test_module_name():
assert tomli.TOMLDecodeError().__module__ == "tomli"
5 changes: 4 additions & 1 deletion tomli/__init__.py
@@ -1,6 +1,9 @@
"""A lil' TOML parser."""

__all__ = ("loads", "load", "TOMLDecodeError")
__version__ = "1.2.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
__version__ = "1.2.2" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT

from tomli._parser import TOMLDecodeError, load, loads

# Pretend this exception was created here.
TOMLDecodeError.__module__ = "tomli"
10 changes: 2 additions & 8 deletions tomli/_parser.py
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Iterable
import string
from types import MappingProxyType
from typing import Any, BinaryIO, Callable, NamedTuple, Tuple
from typing import Any, BinaryIO, NamedTuple
import warnings

from tomli._re import (
Expand All @@ -14,6 +14,7 @@
match_to_localtime,
match_to_number,
)
from tomli._types import Key, ParseFloat, Pos

ASCII_CTRL = frozenset(chr(i) for i in range(32)) | frozenset(chr(127))

Expand Down Expand Up @@ -45,13 +46,6 @@
}
)

# Type annotations
Pos = int
# Use `collections.abc.Callable` when min Python is 3.9
ParseFloat = Callable[[str], Any]
# use `tuple` when min Python is 3.9
Key = Tuple[str, ...]


class TOMLDecodeError(ValueError):
"""An error raised if a document is not valid TOML."""
Expand Down
5 changes: 2 additions & 3 deletions tomli/_re.py
Expand Up @@ -3,10 +3,9 @@
from datetime import date, datetime, time, timedelta, timezone, tzinfo
from functools import lru_cache
import re
from typing import TYPE_CHECKING, Any
from typing import Any

if TYPE_CHECKING:
from tomli._parser import ParseFloat
from tomli._types import ParseFloat

# E.g.
# - 00:32:00.999999
Expand Down
6 changes: 6 additions & 0 deletions tomli/_types.py
@@ -0,0 +1,6 @@
from typing import Any, Callable, Tuple

# Type annotations
ParseFloat = Callable[[str], Any]
Key = Tuple[str, ...]
Pos = int

0 comments on commit 5be5bfd

Please sign in to comment.