[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1033815: unblock: python-tomlkit/0.11.7-1



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package python-tomlkit

[ Reason ]
This is a purely bugfix update and the release will be better for not
having these bugs present.  I didn't realize this was a key package when
I did the upload and it would be better to let it in so that Unstable is
available for any future fixes that might be needed.

[ Impact ]
The following bugs will be present in Bookworm if the unblock isn't
granted:

- Parse empty table name if it is quoted.
  ([#258](https://github.com/sdispater/tomlkit/issues/258))
- Fix a bug that remove last element of an Inline Table leaves a comma.
  ([#259](https://github.com/sdispater/tomlkit/issues/259))
- Parse datetime when it is followed by a space.
  ([#260](https://github.com/sdispater/tomlkit/issues/260))
- Fix the `unwrap()` method for `Container` children values which sometimes
  returns an internal object if the table is an out-of-order table.
  ([#264](https://github.com/sdispater/tomlkit/issues/264))
- Fix the wrong return type when doing arithmetic operations between integers
  and floats. ([#270](https://github.com/sdispater/tomlkit/issues/270))

[ Tests ]
Upstream tests are run during build and in an autopkgtest and both have
succeeded.  Tests were added along with the bug fixes to cover them.

[Risks ]
Diff is small and has test coverage, so risk is very low.  This is a key
package (to my surprise) because of pylint.  The chances of these
changes causing problems with pylint is negligible.

[ Checklist ]
  [X] all changes are documented in the d/changelog
  [X] I reviewed all changes and I approve them
  [X] attach debdiff against the package in testing

[ Other info ]
(Anything else the release team should know.)

unblock python-tomlkit/0.11.7-1
diff -Nru python-tomlkit-0.11.6/CHANGELOG.md python-tomlkit-0.11.7/CHANGELOG.md
--- python-tomlkit-0.11.6/CHANGELOG.md	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/CHANGELOG.md	2023-03-27 03:39:07.123327000 -0400
@@ -2,6 +2,16 @@
 
 ## [Unreleased]
 
+## [0.11.7] - 2023-03-27
+
+### Fixed
+
+- Parse empty table name if it is quoted. ([#258](https://github.com/sdispater/tomlkit/issues/258))
+- Fix a bug that remove last element of an Inline Table leaves a comma. ([#259](https://github.com/sdispater/tomlkit/issues/259))
+- Parse datetime when it is followed by a space. ([#260](https://github.com/sdispater/tomlkit/issues/260))
+- Fix the `unwrap()` method for `Container` children values which sometimes returns an internal object if the table is an out-of-order table. ([#264](https://github.com/sdispater/tomlkit/issues/264))
+- Fix the wrong return type when doing arithmetic operations between integers and floats. ([#270](https://github.com/sdispater/tomlkit/issues/270))
+
 ## [0.11.6] - 2022-10-27
 
 ### Fixed
@@ -329,7 +339,8 @@
 - Fixed handling of super tables with different sections.
 - Fixed raw strings escaping.
 
-[unreleased]: https://github.com/sdispater/tomlkit/compare/0.11.6...master
+[unreleased]: https://github.com/sdispater/tomlkit/compare/0.11.7...master
+[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
 [0.11.5]: https://github.com/sdispater/tomlkit/releases/tag/0.11.5
 [0.11.4]: https://github.com/sdispater/tomlkit/releases/tag/0.11.4
diff -Nru python-tomlkit-0.11.6/debian/changelog python-tomlkit-0.11.7/debian/changelog
--- python-tomlkit-0.11.6/debian/changelog	2022-11-01 00:53:32.000000000 -0400
+++ python-tomlkit-0.11.7/debian/changelog	2023-04-01 16:34:39.000000000 -0400
@@ -1,3 +1,10 @@
+python-tomlkit (0.11.7-1) unstable; urgency=medium
+
+  * New upstream release
+  * Bump standards-version to 4.6.2 without further change
+
+ -- Scott Kitterman <scott@kitterman.com>  Sat, 01 Apr 2023 16:34:39 -0400
+
 python-tomlkit (0.11.6-1) unstable; urgency=medium
 
   * New upstream release
diff -Nru python-tomlkit-0.11.6/debian/control python-tomlkit-0.11.7/debian/control
--- python-tomlkit-0.11.6/debian/control	2022-11-01 00:49:21.000000000 -0400
+++ python-tomlkit-0.11.7/debian/control	2023-04-01 16:34:39.000000000 -0400
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Debian Python Team <team+python@tracker.debian.org>
 Uploaders: Scott Kitterman <scott@kitterman.com>
-Standards-Version: 4.6.1
+Standards-Version: 4.6.2
 Build-Depends:
  debhelper-compat (= 12),
  dh-python,
diff -Nru python-tomlkit-0.11.6/docs/api.rst python-tomlkit-0.11.7/docs/api.rst
--- python-tomlkit-0.11.6/docs/api.rst	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/docs/api.rst	2023-03-27 03:39:07.123327000 -0400
@@ -35,8 +35,6 @@
 TOML Items
 ----------
 
-.. module:: tomlkit.items
-
 .. automodule:: tomlkit.items
    :show-inheritance:
    :members:
diff -Nru python-tomlkit-0.11.6/docs/conf.py python-tomlkit-0.11.7/docs/conf.py
--- python-tomlkit-0.11.6/docs/conf.py	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/docs/conf.py	2023-03-27 03:39:07.123327000 -0400
@@ -57,4 +57,4 @@
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ["_static"]
+html_static_path = []
diff -Nru python-tomlkit-0.11.6/PKG-INFO python-tomlkit-0.11.7/PKG-INFO
--- python-tomlkit-0.11.6/PKG-INFO	1969-12-31 19:00:00.000000000 -0500
+++ python-tomlkit-0.11.7/PKG-INFO	1969-12-31 19:00:00.000000000 -0500
@@ -1,15 +1,14 @@
 Metadata-Version: 2.1
 Name: tomlkit
-Version: 0.11.6
+Version: 0.11.7
 Summary: Style preserving TOML library
 Home-page: https://github.com/sdispater/tomlkit
 License: MIT
 Author: Sébastien Eustace
 Author-email: sebastien@eustace.io
-Requires-Python: >=3.6
+Requires-Python: >=3.7
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
 Classifier: Programming Language :: Python :: 3.8
 Classifier: Programming Language :: Python :: 3.9
diff -Nru python-tomlkit-0.11.6/pyproject.toml python-tomlkit-0.11.7/pyproject.toml
--- python-tomlkit-0.11.6/pyproject.toml	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/pyproject.toml	2023-03-27 03:39:07.123327000 -0400
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "tomlkit"
-version = "0.11.6"
+version = "0.11.7"
 description = "Style preserving TOML library"
 authors = ["Sébastien Eustace <sebastien@eustace.io>"]
 license = "MIT"
@@ -18,16 +18,16 @@
 ]
 
 [tool.poetry.dependencies]
-python = ">=3.6"
+python = ">=3.7"
 
 [tool.poetry.dev-dependencies]
-pytest = "^6.2.5"
-pytest-cov = "^3.0.0"
+pytest = "^7.2.0"
+pytest-cov = "^4.0.0"
 PyYAML = "^6.0"
-pre-commit = {version = "^2.1.0", python = "^3.6.1"}
-mypy = "^0.920"
+pre-commit = "^2.20.0"
+mypy = "^0.990"
 Sphinx = "^4.3.2"
-furo = "^2021.11.23"
+furo = "^2022.9.29"
 
 [tool.black]
 line-length = 88
diff -Nru python-tomlkit-0.11.6/setup.py python-tomlkit-0.11.7/setup.py
--- python-tomlkit-0.11.6/setup.py	1969-12-31 19:00:00.000000000 -0500
+++ python-tomlkit-0.11.7/setup.py	1969-12-31 19:00:00.000000000 -0500
@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-from setuptools import setup
-
-packages = \
-['tomlkit']
-
-package_data = \
-{'': ['*']}
-
-setup_kwargs = {
-    'name': 'tomlkit',
-    'version': '0.11.6',
-    'description': 'Style preserving TOML library',
-    'long_description': '[github_release]: https://img.shields.io/github/release/sdispater/tomlkit.svg?logo=github&logoColor=white\n[pypi_version]: https://img.shields.io/pypi/v/tomlkit.svg?logo=python&logoColor=white\n[python_versions]: https://img.shields.io/pypi/pyversions/tomlkit.svg?logo=python&logoColor=white\n[github_license]: https://img.shields.io/github/license/sdispater/tomlkit.svg?logo=github&logoColor=white\n[github_action]: https://github.com/sdispater/tomlkit/actions/workflows/tests.yml/badge.svg\n\n[![GitHub Release][github_release]](https://github.com/sdispater/tomlkit/releases/)\n[![PyPI Version][pypi_version]](https://pypi.org/project/tomlkit/)\n[![Python Versions][python_versions]](https://pypi.org/project/tomlkit/)\n[![License][github_license]](https://github.com/sdispater/tomlkit/blob/master/LICENSE)\n<br>\n[![Tests][github_action]](https://github.com/sdispater/tomlkit/actions/workflows/tests.yml)\n\n# TOML Kit - Style-preserving TOML library for Python\n\nTOML Kit is a **1.0.0-compliant** [TOML](https://toml.io/) library.\n\nIt includes a parser that preserves all comments, indentations, whitespace and internal element ordering,\nand makes them accessible and editable via an intuitive API.\n\nYou can also create new TOML documents from scratch using the provided helpers.\n\nPart of the implementation has been adapted, improved and fixed from [Molten](https://github.com/LeopoldArkham/Molten).\n\n## Usage\n\nSee the [documentation](https://github.com/sdispater/tomlkit/blob/master/docs/quickstart.rst) for more information.\n\n## Installation\n\nIf you are using [Poetry](https://poetry.eustace.io),\nadd `tomlkit` to your `pyproject.toml` file by using:\n\n```bash\npoetry add tomlkit\n```\n\nIf not, you can use `pip`:\n\n```bash\npip install tomlkit\n```\n\n## Running tests\n\nPlease clone the repo with submodules with the following command\n`git clone --recurse-submodules https://github.com/sdispater/tomlkit.git`.\nWe need the submodule - `toml-test` for running the tests.\n\nYou can run the tests with `poetry run pytest -q tests`\n',
-    'author': 'Sébastien Eustace',
-    'author_email': 'sebastien@eustace.io',
-    'maintainer': 'None',
-    'maintainer_email': 'None',
-    'url': 'https://github.com/sdispater/tomlkit',
-    'packages': packages,
-    'package_data': package_data,
-    'python_requires': '>=3.6',
-}
-
-
-setup(**setup_kwargs)
diff -Nru python-tomlkit-0.11.6/tests/test_api.py python-tomlkit-0.11.7/tests/test_api.py
--- python-tomlkit-0.11.6/tests/test_api.py	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/tests/test_api.py	2023-03-27 03:39:07.123327000 -0400
@@ -458,3 +458,10 @@
 def test_create_string_with_invalid_characters(kwargs, example):
     with pytest.raises(InvalidStringError):
         tomlkit.string(example, **kwargs)
+
+
+def test_parse_empty_quoted_table_name():
+    content = "['']\nx = 1\n"
+    parsed = loads(content)
+    assert parsed == {"": {"x": 1}}
+    assert dumps(parsed) == content
diff -Nru python-tomlkit-0.11.6/tests/test_items.py python-tomlkit-0.11.7/tests/test_items.py
--- python-tomlkit-0.11.6/tests/test_items.py	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/tests/test_items.py	2023-03-27 03:39:07.123327000 -0400
@@ -307,6 +307,7 @@
     content = """a = [1, 2,] # Comment
 """
     doc = parse(content)
+    assert str(doc["a"]) == "[1, 2]"
 
     assert doc["a"] == [1, 2]
     doc["a"] += [3, 4]
@@ -578,6 +579,29 @@
     )
 
 
+def test_add_float_to_int():
+    content = "[table]\nmy_int = 2043"
+    doc = parse(content)
+    doc["table"]["my_int"] += 5.0
+    assert doc["table"]["my_int"] == 2048.0
+    assert isinstance(doc["table"]["my_int"], float)
+
+
+def test_sub_float_from_int():
+    content = "[table]\nmy_int = 2048"
+    doc = parse(content)
+    doc["table"]["my_int"] -= 5.0
+    assert doc["table"]["my_int"] == 2043.0
+    assert isinstance(doc["table"]["my_int"], float)
+
+
+def test_sub_int_from_float():
+    content = "[table]\nmy_int = 2048.0"
+    doc = parse(content)
+    doc["table"]["my_int"] -= 5
+    assert doc["table"]["my_int"] == 2043.0
+
+
 def test_add_sum_int_with_float():
     content = "[table]\nmy_int = 2048.3"
     doc = parse(content)
@@ -677,6 +701,17 @@
     assert doc.as_string() == "dt = 2018-07-23 # Comment"
 
 
+def test_parse_datetime_followed_by_space():
+    # issue #260
+    doc = parse("dt = 2018-07-22 ")
+    assert doc["dt"] == date(2018, 7, 22)
+    assert doc.as_string() == "dt = 2018-07-22 "
+
+    doc = parse("dt = 2013-01-24 13:48:01.123456 ")
+    assert doc["dt"] == datetime(2013, 1, 24, 13, 48, 1, 123456)
+    assert doc.as_string() == "dt = 2013-01-24 13:48:01.123456 "
+
+
 def test_times_behave_like_times():
     i = item(time(12, 34, 56))
 
@@ -824,7 +859,7 @@
     assert table.as_string() == '{foo = "bar", baz = "foobaz"}'
 
 
-def test_deleting_inline_table_elemeent_does_not_leave_trailing_separator():
+def test_deleting_inline_table_element_does_not_leave_trailing_separator():
     table = api.inline_table()
     table["foo"] = "bar"
     table["baz"] = "boom"
@@ -845,6 +880,22 @@
     assert table.as_string() == '{baz = "boom"}'
 
 
+def test_deleting_inline_table_element_does_not_leave_trailing_separator2():
+    doc = parse('a = {foo = "bar", baz = "boom"}')
+    table = doc["a"]
+    assert table.as_string() == '{foo = "bar", baz = "boom"}'
+
+    del table["baz"]
+    assert table.as_string() == '{foo = "bar" }'
+
+    del table["foo"]
+    assert table.as_string() == "{ }"
+
+    table["baz"] = "boom"
+
+    assert table.as_string() == '{ baz = "boom"}'
+
+
 def test_booleans_comparison():
     boolean = Bool(True, Trivia())
 
diff -Nru python-tomlkit-0.11.6/tests/test_write.py python-tomlkit-0.11.7/tests/test_write.py
--- python-tomlkit-0.11.6/tests/test_write.py	2022-10-27 04:20:48.030500700 -0400
+++ python-tomlkit-0.11.7/tests/test_write.py	2023-03-27 03:39:07.127327200 -0400
@@ -21,6 +21,6 @@
 
 def test_write_inline_table_in_nested_arrays():
     d = {"foo": [[{"a": 1}]]}
-    expected = "foo = [[{a = 1}]]\n"  # noqa: FS003
+    expected = "foo = [[{a = 1}]]\n"
     assert expected == dumps(d)
     assert loads(dumps(d))["foo"] == [[{"a": 1}]]
diff -Nru python-tomlkit-0.11.6/tomlkit/api.py python-tomlkit-0.11.7/tomlkit/api.py
--- python-tomlkit-0.11.6/tomlkit/api.py	2022-10-27 04:20:48.046501400 -0400
+++ python-tomlkit-0.11.7/tomlkit/api.py	2023-03-27 03:39:07.139327800 -0400
@@ -59,7 +59,7 @@
         raise TypeError(msg) from ex
 
 
-def load(fp: IO) -> TOMLDocument:
+def load(fp: Union[IO[str], IO[bytes]]) -> TOMLDocument:
     """
     Load toml document from a file-like object.
     """
@@ -119,7 +119,7 @@
     boolean flags (e.g. ``literal=True`` and/or ``multiline=True``)
     can be used for personalization.
 
-    For more information, please check the spec: `https://toml.io/en/v1.0.0#string`_.
+    For more information, please check the spec: `<https://toml.io/en/v1.0.0#string>`__.
 
     Common escaping rules will be applied for basic strings.
     This can be controlled by explicitly setting ``escape=False``.
diff -Nru python-tomlkit-0.11.6/tomlkit/container.py python-tomlkit-0.11.7/tomlkit/container.py
--- python-tomlkit-0.11.6/tomlkit/container.py	2022-10-27 04:20:48.046501400 -0400
+++ python-tomlkit-0.11.7/tomlkit/container.py	2023-03-27 03:39:07.139327800 -0400
@@ -55,7 +55,7 @@
             if isinstance(k, Key):
                 k = k.key
 
-            if isinstance(v, Item):
+            if hasattr(v, "unwrap"):
                 v = v.unwrap()
 
             if k in unwrapped:
diff -Nru python-tomlkit-0.11.6/tomlkit/__init__.py python-tomlkit-0.11.7/tomlkit/__init__.py
--- python-tomlkit-0.11.6/tomlkit/__init__.py	2022-10-27 04:20:48.046501400 -0400
+++ python-tomlkit-0.11.7/tomlkit/__init__.py	2023-03-27 03:39:07.139327800 -0400
@@ -25,7 +25,7 @@
 from tomlkit.api import ws
 
 
-__version__ = "0.11.6"
+__version__ = "0.11.7"
 __all__ = [
     "aot",
     "array",
diff -Nru python-tomlkit-0.11.6/tomlkit/items.py python-tomlkit-0.11.7/tomlkit/items.py
--- python-tomlkit-0.11.6/tomlkit/items.py	2022-10-27 04:20:48.046501400 -0400
+++ python-tomlkit-0.11.7/tomlkit/items.py	2023-03-27 03:39:07.139327800 -0400
@@ -647,28 +647,28 @@
         return self._raw
 
     def __add__(self, other):
-        return self._new(int(self._raw) + other)
+        result = super().__add__(other)
+        if result is NotImplemented:
+            return result
+        return self._new(result)
 
     def __radd__(self, other):
         result = super().__radd__(other)
-
-        if isinstance(other, Integer):
-            return self._new(result)
-
-        return result
+        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 isinstance(other, Integer):
-            return self._new(result)
-
-        return result
+        if result is NotImplemented:
+            return result
+        return self._new(result)
 
     def _new(self, result):
         raw = str(result)
@@ -1130,7 +1130,7 @@
         super().__init__(trivia)
         list.__init__(
             self,
-            [v.value for v in value if not isinstance(v, (Whitespace, Comment, Null))],
+            [v for v in value if not isinstance(v, (Whitespace, Comment, Null))],
         )
         self._index_map: Dict[int, int] = {}
         self._value = self._group_values(value)
@@ -1166,7 +1166,7 @@
     def unwrap(self) -> List[Any]:
         unwrapped = []
         for v in self:
-            if isinstance(v, Item):
+            if hasattr(v, "unwrap"):
                 unwrapped.append(v.unwrap())
             else:
                 unwrapped.append(v)
@@ -1317,11 +1317,14 @@
         return list.__len__(self)
 
     def __getitem__(self, key: Union[int, slice]) -> Any:
-        return list.__getitem__(self, key)
+        rv = cast(Item, list.__getitem__(self, key))
+        if rv.is_boolean():
+            return bool(rv)
+        return rv
 
     def __setitem__(self, key: Union[int, slice], value: Any) -> Any:
         it = item(value, _parent=self)
-        list.__setitem__(self, key, it.value)
+        list.__setitem__(self, key, it)
         if isinstance(key, slice):
             raise ValueError("slice assignment is not supported")
         if key < 0:
@@ -1332,7 +1335,7 @@
         it = item(value, _parent=self)
         length = len(self)
         if not isinstance(it, (Comment, Whitespace)):
-            list.insert(self, pos, it.value)
+            list.insert(self, pos, it)
         if pos < 0:
             pos += length
             if pos < 0:
@@ -1411,9 +1414,6 @@
 
         self._reindex()
 
-    def __str__(self):
-        return str([v.value.value for v in self._iter_items() if v.value is not None])
-
     def _getstate(self, protocol=3):
         return list(self._iter_items()), self._trivia, self._multiline
 
@@ -1438,7 +1438,7 @@
         for k, v in self.items():
             if isinstance(k, Key):
                 k = k.key
-            if isinstance(v, Item):
+            if hasattr(v, "unwrap"):
                 v = v.unwrap()
             unwrapped[k] = v
 
@@ -1716,6 +1716,14 @@
 
     def as_string(self) -> str:
         buf = "{"
+        last_item_idx = next(
+            (
+                i
+                for i in range(len(self._value.body) - 1, -1, -1)
+                if self._value.body[i][0] is not None
+            ),
+            None,
+        )
         for i, (k, v) in enumerate(self._value.body):
             if k is None:
                 if i == len(self._value.body) - 1:
@@ -1738,7 +1746,7 @@
                 f"{v_trivia_trail}"
             )
 
-            if i != len(self._value.body) - 1:
+            if last_item_idx is not None and i < last_item_idx:
                 buf += ","
                 if self._new:
                     buf += " "
@@ -1835,7 +1843,7 @@
     def unwrap(self) -> List[Dict[str, Any]]:
         unwrapped = []
         for t in self._body:
-            if isinstance(t, Item):
+            if hasattr(t, "unwrap"):
                 unwrapped.append(t.unwrap())
             else:
                 unwrapped.append(t)
diff -Nru python-tomlkit-0.11.6/tomlkit/parser.py python-tomlkit-0.11.7/tomlkit/parser.py
--- python-tomlkit-0.11.6/tomlkit/parser.py	2022-10-27 04:20:48.046501400 -0400
+++ python-tomlkit-0.11.7/tomlkit/parser.py	2023-03-27 03:39:07.139327800 -0400
@@ -497,11 +497,12 @@
                             pass
 
                         time_raw = self.extract()
-                        if not time_raw.strip():
-                            trivia.comment_ws = time_raw
+                        time_part = time_raw.rstrip()
+                        trivia.comment_ws = time_raw[len(time_part) :]
+                        if not time_part:
                             return date
 
-                        dt = parse_rfc3339(raw + time_raw)
+                        dt = parse_rfc3339(raw + time_part)
                         assert isinstance(dt, datetime.datetime)
                         return DateTime(
                             dt.year,
@@ -513,7 +514,7 @@
                             dt.microsecond,
                             dt.tzinfo,
                             trivia,
-                            raw + time_raw,
+                            raw + time_part,
                         )
                     except ValueError:
                         raise self.parse_error(InvalidDateError)
@@ -910,8 +911,6 @@
             raise self.parse_error(UnexpectedEofError)
         elif self._current != "]":
             raise self.parse_error(UnexpectedCharError, self._current)
-        elif not key.key.strip():
-            raise self.parse_error(EmptyTableNameError)
 
         key.sep = ""
         full_key = key

Reply to: