Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-tomlkit for openSUSE:Factory checked in at 2023-09-07 21:13:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tomlkit (Old) and /work/SRC/openSUSE:Factory/.python-tomlkit.new.1766 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tomlkit" Thu Sep 7 21:13:49 2023 rev:15 rq:1109526 version:0.12.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tomlkit/python-tomlkit.changes 2023-05-14 16:34:24.667982817 +0200 +++ /work/SRC/openSUSE:Factory/.python-tomlkit.new.1766/python-tomlkit.changes 2023-09-07 21:15:31.755285710 +0200 @@ -1,0 +2,13 @@ +Thu Sep 7 11:29:45 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 0.12.1: + * Make float and int hashable. + * Allow users to specify encoders for custom types. (#296) + * Fix the incorrect sort when building a table with dotted + keys. + * Complete the methods required for integer and float items. + * Replace the deprecated usage of `datetime.utcnow()`. (#308) + * Minor performance improvements when iterating over the escape + sequences. (#304) + +------------------------------------------------------------------- Old: ---- tomlkit-0.11.8.tar.gz New: ---- tomlkit-0.12.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tomlkit.spec ++++++ --- /var/tmp/diff_new_pack.DN1iY2/_old 2023-09-07 21:15:32.751321315 +0200 +++ /var/tmp/diff_new_pack.DN1iY2/_new 2023-09-07 21:15:32.751321315 +0200 @@ -16,10 +16,9 @@ # -%define skip_python2 1 %{?sle15_python_module_pythons} Name: python-tomlkit -Version: 0.11.8 +Version: 0.12.1 Release: 0 Summary: Style preserving TOML library License: MIT ++++++ tomlkit-0.11.8.tar.gz -> tomlkit-0.12.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/CHANGELOG.md new/tomlkit-0.12.1/CHANGELOG.md --- old/tomlkit-0.11.8/CHANGELOG.md 2023-04-27 12:38:57.552470000 +0200 +++ new/tomlkit-0.12.1/CHANGELOG.md 2023-07-27 16:49:58.240415600 +0200 @@ -1,5 +1,24 @@ # Change Log +## [0.12.1] - 2023-07-27 + +### Fixed + +- Make float and int hashable. + +## [0.12.0] - 2023-07-27 + +### Added + +- Allow users to specify encoders for custom types. ([#296](https://github.com/sdispater/tomlkit/issues/296)) + +### Fixed + +- Fix the incorrect sort when building a table with dotted keys. +- Complete the methods required for integer and float items. ([#307](https://github.com/sdispater/tomlkit/issues/307)) +- Replace the deprecated usage of `datetime.utcnow()`. ([#308](https://github.com/sdispater/tomlkit/issues/308)) +- Minor performance improvements when iterating over the escape sequences. ([#304](https://github.com/sdispater/tomlkit/issues/304)) + ## [0.11.8] - 2023-04-27 ### Fixed @@ -346,7 +365,9 @@ - Fixed handling of super tables with different sections. - Fixed raw strings escaping. -[unreleased]: https://github.com/sdispater/tomlkit/compare/0.11.8...master +[unreleased]: https://github.com/sdispater/tomlkit/compare/0.12.1...master +[0.12.1]: https://github.com/sdispater/tomlkit/releases/tag/0.12.1 +[0.12.0]: https://github.com/sdispater/tomlkit/releases/tag/0.12.0 [0.11.8]: https://github.com/sdispater/tomlkit/releases/tag/0.11.8 [0.11.7]: https://github.com/sdispater/tomlkit/releases/tag/0.11.7 [0.11.6]: https://github.com/sdispater/tomlkit/releases/tag/0.11.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/PKG-INFO new/tomlkit-0.12.1/PKG-INFO --- old/tomlkit-0.11.8/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/tomlkit-0.12.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tomlkit -Version: 0.11.8 +Version: 0.12.1 Summary: Style preserving TOML library Home-page: https://github.com/sdispater/tomlkit License: MIT @@ -43,7 +43,7 @@ ## Usage -See the [documentation](https://github.com/sdispater/tomlkit/blob/master/docs/quickstart.rst) for more information. +See the [documentation](https://tomlkit.readthedocs.io/) for more information. ## Installation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/README.md new/tomlkit-0.12.1/README.md --- old/tomlkit-0.11.8/README.md 2023-04-27 12:38:57.552470000 +0200 +++ new/tomlkit-0.12.1/README.md 2023-07-27 16:49:58.240415600 +0200 @@ -24,7 +24,7 @@ ## Usage -See the [documentation](https://github.com/sdispater/tomlkit/blob/master/docs/quickstart.rst) for more information. +See the [documentation](https://tomlkit.readthedocs.io/) for more information. ## Installation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/pyproject.toml new/tomlkit-0.12.1/pyproject.toml --- old/tomlkit-0.11.8/pyproject.toml 2023-04-27 12:38:57.552470000 +0200 +++ new/tomlkit-0.12.1/pyproject.toml 2023-07-27 16:49:58.240415600 +0200 @@ -1,6 +1,6 @@ [tool.poetry] name = "tomlkit" -version = "0.11.8" +version = "0.12.1" description = "Style preserving TOML library" authors = [ "Sébastien Eustace <sebast...@eustace.io>", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tests/test_items.py new/tomlkit-0.12.1/tests/test_items.py --- old/tomlkit-0.11.8/tests/test_items.py 2023-04-27 12:38:57.556470000 +0200 +++ new/tomlkit-0.12.1/tests/test_items.py 2023-07-27 16:49:58.240415600 +0200 @@ -6,6 +6,7 @@ from datetime import datetime from datetime import time from datetime import timedelta +from datetime import timezone import pytest @@ -103,7 +104,7 @@ def test_datetime_unwrap(): - dt = datetime.utcnow() + dt = datetime.now(tz=timezone.utc) elementary_test(item(dt), datetime) @@ -946,3 +947,21 @@ ) def test_escape_key(key_str, escaped): assert api.key(key_str).as_string() == escaped + + +def test_custom_encoders(): + import decimal + + @api.register_encoder + def encode_decimal(obj): + if isinstance(obj, decimal.Decimal): + return api.float_(str(obj)) + raise TypeError + + assert api.item(decimal.Decimal("1.23")).as_string() == "1.23" + + with pytest.raises(TypeError): + api.item(object()) + + assert api.dumps({"foo": decimal.Decimal("1.23")}) == "foo = 1.23\n" + api.unregister_encoder(encode_decimal) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tests/test_toml_document.py new/tomlkit-0.12.1/tests/test_toml_document.py --- old/tomlkit-0.11.8/tests/test_toml_document.py 2023-04-27 12:38:57.556470000 +0200 +++ new/tomlkit-0.12.1/tests/test_toml_document.py 2023-07-27 16:49:58.240415600 +0200 @@ -1072,3 +1072,15 @@ """ doc = parse(expected) assert doc.as_string() == expected + + +def test_item_preserves_the_order(): + t = tomlkit.inline_table() + t.update({"a": 1, "b": 2}) + doc = {"name": "foo", "table": t, "age": 42} + expected = """\ +name = "foo" +table = {a = 1, b = 2} +age = 42 +""" + assert tomlkit.dumps(doc) == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/__init__.py new/tomlkit-0.12.1/tomlkit/__init__.py --- old/tomlkit-0.11.8/tomlkit/__init__.py 2023-04-27 12:38:57.564469800 +0200 +++ new/tomlkit-0.12.1/tomlkit/__init__.py 2023-07-27 16:49:58.252415700 +0200 @@ -18,14 +18,16 @@ from tomlkit.api import loads from tomlkit.api import nl from tomlkit.api import parse +from tomlkit.api import register_encoder from tomlkit.api import string from tomlkit.api import table from tomlkit.api import time +from tomlkit.api import unregister_encoder from tomlkit.api import value from tomlkit.api import ws -__version__ = "0.11.8" +__version__ = "0.12.1" __all__ = [ "aot", "array", @@ -52,4 +54,6 @@ "TOMLDocument", "value", "ws", + "register_encoder", + "unregister_encoder", ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/_types.py new/tomlkit-0.12.1/tomlkit/_types.py --- old/tomlkit-0.11.8/tomlkit/_types.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tomlkit-0.12.1/tomlkit/_types.py 2023-07-27 16:49:58.252415700 +0200 @@ -0,0 +1,65 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING +from typing import Any +from typing import TypeVar + + +WT = TypeVar("WT", bound="WrapperType") + +if TYPE_CHECKING: # pragma: no cover + # Define _CustomList and _CustomDict as a workaround for: + # https://github.com/python/mypy/issues/11427 + # + # According to this issue, the typeshed contains a "lie" + # (it adds MutableSequence to the ancestry of list and MutableMapping to + # the ancestry of dict) which completely messes with the type inference for + # Table, InlineTable, Array and Container. + # + # Importing from builtins is preferred over simple assignment, see issues: + # https://github.com/python/mypy/issues/8715 + # https://github.com/python/mypy/issues/10068 + from builtins import dict as _CustomDict # noqa: N812 + from builtins import float as _CustomFloat # noqa: N812 + from builtins import int as _CustomInt # noqa: N812 + from builtins import list as _CustomList # noqa: N812 + from typing import Callable + from typing import Concatenate + from typing import ParamSpec + from typing import Protocol + + P = ParamSpec("P") + + class WrapperType(Protocol): + def _new(self: WT, value: Any) -> WT: + ... + +else: + from collections.abc import MutableMapping + from collections.abc import MutableSequence + from numbers import Integral + from numbers import Real + + class _CustomList(MutableSequence, list): + """Adds MutableSequence mixin while pretending to be a builtin list""" + + class _CustomDict(MutableMapping, dict): + """Adds MutableMapping mixin while pretending to be a builtin dict""" + + class _CustomInt(Integral, int): + """Adds Integral mixin while pretending to be a builtin int""" + + class _CustomFloat(Real, float): + """Adds Real mixin while pretending to be a builtin float""" + + +def wrap_method( + original_method: Callable[Concatenate[WT, P], Any] +) -> Callable[Concatenate[WT, P], Any]: + def wrapper(self: WT, *args: P.args, **kwargs: P.kwargs) -> Any: + result = original_method(self, *args, **kwargs) + if result is NotImplemented: + return result + return self._new(result) + + return wrapper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/_utils.py new/tomlkit-0.12.1/tomlkit/_utils.py --- old/tomlkit-0.11.8/tomlkit/_utils.py 2023-04-27 12:38:57.564469800 +0200 +++ new/tomlkit-0.12.1/tomlkit/_utils.py 2023-07-27 16:49:58.252415700 +0200 @@ -133,9 +133,11 @@ return i + inc + found_sequences = {seq for seq in escape_sequences if seq in s} + i = 0 while i < len(s): - for seq in escape_sequences: + for seq in found_sequences: seq_len = len(seq) if s[i:].startswith(seq): start = flush(seq_len) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/api.py new/tomlkit-0.12.1/tomlkit/api.py --- old/tomlkit-0.11.8/tomlkit/api.py 2023-04-27 12:38:57.564469800 +0200 +++ new/tomlkit-0.12.1/tomlkit/api.py 2023-07-27 16:49:58.252415700 +0200 @@ -1,14 +1,17 @@ from __future__ import annotations +import contextlib import datetime as _datetime from collections.abc import Mapping from typing import IO from typing import Iterable +from typing import TypeVar from tomlkit._utils import parse_rfc3339 from tomlkit.container import Container from tomlkit.exceptions import UnexpectedCharError +from tomlkit.items import CUSTOM_ENCODERS from tomlkit.items import AoT from tomlkit.items import Array from tomlkit.items import Bool @@ -16,6 +19,7 @@ from tomlkit.items import Date from tomlkit.items import DateTime from tomlkit.items import DottedKey +from tomlkit.items import Encoder from tomlkit.items import Float from tomlkit.items import InlineTable from tomlkit.items import Integer @@ -284,3 +288,21 @@ def comment(string: str) -> Comment: """Create a comment item.""" return Comment(Trivia(comment_ws=" ", comment="# " + string)) + + +E = TypeVar("E", bound=Encoder) + + +def register_encoder(encoder: E) -> E: + """Add a custom encoder, which should be a function that will be called + if the value can't otherwise be converted. It should takes a single value + and return a TOMLKit item or raise a ``TypeError``. + """ + CUSTOM_ENCODERS.append(encoder) + return encoder + + +def unregister_encoder(encoder: Encoder) -> None: + """Unregister a custom encoder.""" + with contextlib.suppress(ValueError): + CUSTOM_ENCODERS.remove(encoder) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/container.py new/tomlkit-0.12.1/tomlkit/container.py --- old/tomlkit-0.11.8/tomlkit/container.py 2023-04-27 12:38:57.568470000 +0200 +++ new/tomlkit-0.12.1/tomlkit/container.py 2023-07-27 16:49:58.252415700 +0200 @@ -6,6 +6,7 @@ from typing import Iterator from tomlkit._compat import decode +from tomlkit._types import _CustomDict from tomlkit._utils import merge_dicts from tomlkit.exceptions import KeyAlreadyPresent from tomlkit.exceptions import NonExistentKey @@ -19,7 +20,6 @@ from tomlkit.items import Table from tomlkit.items import Trivia from tomlkit.items import Whitespace -from tomlkit.items import _CustomDict from tomlkit.items import item as _item diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/items.py new/tomlkit-0.12.1/tomlkit/items.py --- old/tomlkit-0.11.8/tomlkit/items.py 2023-04-27 12:38:57.568470000 +0200 +++ new/tomlkit-0.12.1/tomlkit/items.py 2023-07-27 16:49:58.252415700 +0200 @@ -3,8 +3,10 @@ import abc import copy import dataclasses +import math import re import string +import sys from datetime import date from datetime import datetime @@ -13,6 +15,7 @@ from enum import Enum from typing import TYPE_CHECKING from typing import Any +from typing import Callable from typing import Collection from typing import Iterable from typing import Iterator @@ -23,40 +26,31 @@ from tomlkit._compat import PY38 from tomlkit._compat import decode +from tomlkit._types import _CustomDict +from tomlkit._types import _CustomFloat +from tomlkit._types import _CustomInt +from tomlkit._types import _CustomList +from tomlkit._types import wrap_method from tomlkit._utils import CONTROL_CHARS from tomlkit._utils import escape_string from tomlkit.exceptions import InvalidStringError -if TYPE_CHECKING: # pragma: no cover - # Define _CustomList and _CustomDict as a workaround for: - # https://github.com/python/mypy/issues/11427 - # - # According to this issue, the typeshed contains a "lie" - # (it adds MutableSequence to the ancestry of list and MutableMapping to - # the ancestry of dict) which completely messes with the type inference for - # Table, InlineTable, Array and Container. - # - # Importing from builtins is preferred over simple assignment, see issues: - # https://github.com/python/mypy/issues/8715 - # https://github.com/python/mypy/issues/10068 - from builtins import dict as _CustomDict # noqa: N812, TC004 - from builtins import list as _CustomList # noqa: N812, TC004 - - # Allow type annotations but break circular imports +if TYPE_CHECKING: from tomlkit import container -else: - from collections.abc import MutableMapping - from collections.abc import MutableSequence - class _CustomList(MutableSequence, list): - """Adds MutableSequence mixin while pretending to be a builtin list""" - class _CustomDict(MutableMapping, dict): - """Adds MutableMapping mixin while pretending to be a builtin dict""" +ItemT = TypeVar("ItemT", bound="Item") +Encoder = Callable[[Any], "Item"] +CUSTOM_ENCODERS: list[Encoder] = [] +AT = TypeVar("AT", bound="AbstractTable") -ItemT = TypeVar("ItemT", bound="Item") +class _ConvertError(TypeError, ValueError): + """An internal error raised when item() fails to convert a value. + It should be a TypeError, but due to historical reasons + it needs to subclass ValueError as well. + """ @overload @@ -155,7 +149,7 @@ val = table_constructor(Container(), Trivia(), False) for k, v in sorted( value.items(), - key=lambda i: (isinstance(i[1], dict), i[0] if _sort_keys else 1), + key=lambda i: (isinstance(i[1], dict), i[0]) if _sort_keys else 1, ): val[k] = item(v, _parent=val, _sort_keys=_sort_keys) @@ -218,8 +212,20 @@ Trivia(), value.isoformat(), ) + else: + for encoder in CUSTOM_ENCODERS: + try: + rv = encoder(value) + except TypeError: + pass + else: + if not isinstance(rv, Item): + raise _ConvertError( + f"Custom encoder returned {type(rv)}, not a subclass of Item" + ) + return rv - raise ValueError(f"Invalid type {type(value)}") + raise _ConvertError(f"Invalid type {type(value)}") class StringType(Enum): @@ -434,7 +440,7 @@ class DottedKey(Key): def __init__( self, - keys: Iterable[Key], + keys: Iterable[SingleKey], sep: str | None = None, original: str | None = None, ) -> None: @@ -584,17 +590,17 @@ return f"{self._trivia.indent}{decode(self._trivia.comment)}" -class Integer(int, Item): +class Integer(Item, _CustomInt): """ An integer literal. """ def __new__(cls, value: int, trivia: Trivia, raw: str) -> Integer: - return super().__new__(cls, value) + return int.__new__(cls, value) - def __init__(self, _: int, trivia: Trivia, raw: str) -> None: + def __init__(self, value: int, trivia: Trivia, raw: str) -> None: super().__init__(trivia) - + self._original = value self._raw = raw self._sign = False @@ -602,7 +608,12 @@ self._sign = True def unwrap(self) -> int: - return int(self) + return self._original + + __int__ = unwrap + + def __hash__(self) -> int: + return hash(self.unwrap()) @property def discriminant(self) -> int: @@ -616,30 +627,6 @@ def as_string(self) -> str: return self._raw - def __add__(self, other): - result = super().__add__(other) - if result is NotImplemented: - return result - return self._new(result) - - def __radd__(self, other): - result = super().__radd__(other) - if result is NotImplemented: - return result - return self._new(result) - - def __sub__(self, other): - result = super().__sub__(other) - if result is NotImplemented: - return result - return self._new(result) - - def __rsub__(self, other): - result = super().__rsub__(other) - if result is NotImplemented: - return result - return self._new(result) - def _new(self, result): raw = str(result) if self._sign: @@ -651,18 +638,53 @@ def _getstate(self, protocol=3): return int(self), self._trivia, self._raw + # int methods + __abs__ = wrap_method(int.__abs__) + __add__ = wrap_method(int.__add__) + __and__ = wrap_method(int.__and__) + __ceil__ = wrap_method(int.__ceil__) + __eq__ = int.__eq__ + __floor__ = wrap_method(int.__floor__) + __floordiv__ = wrap_method(int.__floordiv__) + __invert__ = wrap_method(int.__invert__) + __le__ = int.__le__ + __lshift__ = wrap_method(int.__lshift__) + __lt__ = int.__lt__ + __mod__ = wrap_method(int.__mod__) + __mul__ = wrap_method(int.__mul__) + __neg__ = wrap_method(int.__neg__) + __or__ = wrap_method(int.__or__) + __pos__ = wrap_method(int.__pos__) + __pow__ = wrap_method(int.__pow__) + __radd__ = wrap_method(int.__radd__) + __rand__ = wrap_method(int.__rand__) + __rfloordiv__ = wrap_method(int.__rfloordiv__) + __rlshift__ = wrap_method(int.__rlshift__) + __rmod__ = wrap_method(int.__rmod__) + __rmul__ = wrap_method(int.__rmul__) + __ror__ = wrap_method(int.__ror__) + __round__ = wrap_method(int.__round__) + __rpow__ = wrap_method(int.__rpow__) + __rrshift__ = wrap_method(int.__rrshift__) + __rshift__ = wrap_method(int.__rshift__) + __rtruediv__ = wrap_method(int.__rtruediv__) + __rxor__ = wrap_method(int.__rxor__) + __truediv__ = wrap_method(int.__truediv__) + __trunc__ = wrap_method(int.__trunc__) + __xor__ = wrap_method(int.__xor__) -class Float(float, Item): + +class Float(Item, _CustomFloat): """ A float literal. """ - def __new__(cls, value: float, trivia: Trivia, raw: str) -> Integer: - return super().__new__(cls, value) + def __new__(cls, value: float, trivia: Trivia, raw: str) -> Float: + return float.__new__(cls, value) - def __init__(self, _: float, trivia: Trivia, raw: str) -> None: + def __init__(self, value: float, trivia: Trivia, raw: str) -> None: super().__init__(trivia) - + self._original = value self._raw = raw self._sign = False @@ -670,7 +692,12 @@ self._sign = True def unwrap(self) -> float: - return float(self) + return self._original + + __float__ = unwrap + + def __hash__(self) -> int: + return hash(self.unwrap()) @property def discriminant(self) -> int: @@ -684,32 +711,6 @@ def as_string(self) -> str: return self._raw - def __add__(self, other): - result = super().__add__(other) - - return self._new(result) - - def __radd__(self, other): - result = super().__radd__(other) - - if isinstance(other, Float): - return self._new(result) - - return result - - def __sub__(self, other): - result = super().__sub__(other) - - return self._new(result) - - def __rsub__(self, other): - result = super().__rsub__(other) - - if isinstance(other, Float): - return self._new(result) - - return result - def _new(self, result): raw = str(result) @@ -722,6 +723,35 @@ def _getstate(self, protocol=3): return float(self), self._trivia, self._raw + # float methods + __abs__ = wrap_method(float.__abs__) + __add__ = wrap_method(float.__add__) + __eq__ = float.__eq__ + __floordiv__ = wrap_method(float.__floordiv__) + __le__ = float.__le__ + __lt__ = float.__lt__ + __mod__ = wrap_method(float.__mod__) + __mul__ = wrap_method(float.__mul__) + __neg__ = wrap_method(float.__neg__) + __pos__ = wrap_method(float.__pos__) + __pow__ = wrap_method(float.__pow__) + __radd__ = wrap_method(float.__radd__) + __rfloordiv__ = wrap_method(float.__rfloordiv__) + __rmod__ = wrap_method(float.__rmod__) + __rmul__ = wrap_method(float.__rmul__) + __round__ = wrap_method(float.__round__) + __rpow__ = wrap_method(float.__rpow__) + __rtruediv__ = wrap_method(float.__rtruediv__) + __truediv__ = wrap_method(float.__truediv__) + __trunc__ = float.__trunc__ + + if sys.version_info >= (3, 9): + __ceil__ = float.__ceil__ + __floor__ = float.__floor__ + else: + __ceil__ = math.ceil + __floor__ = math.floor + class Bool(Item): """ @@ -1388,9 +1418,6 @@ return list(self._iter_items()), self._trivia, self._multiline -AT = TypeVar("AT", bound="AbstractTable") - - class AbstractTable(Item, _CustomDict): """Common behaviour of both :class:`Table` and :class:`InlineTable`""" @@ -1430,11 +1457,11 @@ raise NotImplementedError @overload - def add(self: AT, value: Comment | Whitespace) -> AT: + def add(self: AT, key: Comment | Whitespace) -> AT: ... @overload - def add(self: AT, key: Key | str, value: Any) -> AT: + def add(self: AT, key: Key | str, value: Any = ...) -> AT: ... def add(self, key, value=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/parser.py new/tomlkit-0.12.1/tomlkit/parser.py --- old/tomlkit-0.11.8/tomlkit/parser.py 2023-04-27 12:38:57.568470000 +0200 +++ new/tomlkit-0.12.1/tomlkit/parser.py 2023-07-27 16:49:58.252415700 +0200 @@ -60,7 +60,7 @@ Parser for TOML documents. """ - def __init__(self, string: str) -> None: + def __init__(self, string: str | bytes) -> None: # Input to parse self._src = Source(decode(string)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tomlkit-0.11.8/tomlkit/source.py new/tomlkit-0.12.1/tomlkit/source.py --- old/tomlkit-0.11.8/tomlkit/source.py 2023-04-27 12:38:57.568470000 +0200 +++ new/tomlkit-0.12.1/tomlkit/source.py 2023-07-27 16:49:58.252415700 +0200 @@ -50,7 +50,7 @@ def __call__(self, *args, **kwargs): return _State(self._source, *args, **kwargs) - def __enter__(self) -> None: + def __enter__(self) -> _State: state = self() self._states.append(state) return state.__enter__()