Skip to content

Commit

Permalink
Revert "fix: Construction of OutOfOrderTableProxy can cause newlines …
Browse files Browse the repository at this point in the history
…to be inserted (#347)"

This reverts commit c2611c5.
  • Loading branch information
frostming committed May 23, 2024
1 parent 987322c commit 0aa5afe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
### Fixed

- Remove the extra minus sign added to the float value after calculation. ([#341](https://github.com/python-poetry/tomlkit/issues/341))
- Fix unexpected newline added after accessing the out-of-order table. ([#343](https://github.com/python-poetry/tomlkit/issues/343))

## [0.12.4] - 2024-02-27

Expand Down
27 changes: 0 additions & 27 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,30 +969,3 @@ def encode_decimal(obj):

assert api.dumps({"foo": decimal.Decimal("1.23")}) == "foo = 1.23\n"
api.unregister_encoder(encode_decimal)


def test_no_extra_minus_sign():
doc = parse("a = -1")
assert doc.as_string() == "a = -1"
doc["a"] *= -1
assert doc.as_string() == "a = +1"
doc["a"] *= -1
assert doc.as_string() == "a = -1"

doc = parse("a = -1.5")
assert doc.as_string() == "a = -1.5"
doc["a"] *= -1
assert doc.as_string() == "a = +1.5"
doc["a"] *= -1
assert doc.as_string() == "a = -1.5"


def test_no_newline_after_visit_oo_table():
content = """\
[a.b.c.d]
[unrelated]
[a.b.e]
"""
doc = parse(content)
doc["a"]
assert doc.as_string() == content
4 changes: 1 addition & 3 deletions tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,6 @@ def __init__(self, container: Container, indices: tuple[int]) -> None:
self._tables = []
self._tables_map = {}

original_parsing = container._parsed
container.parsing(True)
for i in indices:
_, item = self._container._body[i]

Expand All @@ -805,7 +803,7 @@ def __init__(self, container: Container, indices: tuple[int]) -> None:
self._tables_map[k] = table_idx
if k is not None:
dict.__setitem__(self, k.key, v)
container.parsing(original_parsing)

self._internal_container._validate_out_of_order_table()

def unwrap(self) -> str:
Expand Down

0 comments on commit 0aa5afe

Please sign in to comment.