diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 2df26c8..94a23ef 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -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 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3ee5d67..a5eb6c2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index e581cc3..7b0720d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 8efd454..c4426ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" }, diff --git a/tests/test_error.py b/tests/test_error.py index 44f7797..d2d982c 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -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" diff --git a/tomli/__init__.py b/tomli/__init__.py index d99eadc..7bcdbab 100644 --- a/tomli/__init__.py +++ b/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" diff --git a/tomli/_parser.py b/tomli/_parser.py index 53721af..58a831d 100644 --- a/tomli/_parser.py +++ b/tomli/_parser.py @@ -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 ( @@ -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)) @@ -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.""" diff --git a/tomli/_re.py b/tomli/_re.py index 95746e7..fa599d7 100644 --- a/tomli/_re.py +++ b/tomli/_re.py @@ -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 diff --git a/tomli/_types.py b/tomli/_types.py new file mode 100644 index 0000000..e37cc80 --- /dev/null +++ b/tomli/_types.py @@ -0,0 +1,6 @@ +from typing import Any, Callable, Tuple + +# Type annotations +ParseFloat = Callable[[str], Any] +Key = Tuple[str, ...] +Pos = int