Repository: sdispater/tomlkit

Issue:
Cannot dump nested arrays of tables
```python
In [12]: tomlkit.dumps({'a': [[ {'b': 1} ]]})
Out[12]: 'a = [b = 1\n]\n'

In [13]: tomlkit.__version__
Out[13]: '0.11.4'
```

Discussion:

Patch:
diff --git a/tomlkit/items.py b/tomlkit/items.py
index 48bdfc6..43ddecd 100644
--- a/tomlkit/items.py
+++ b/tomlkit/items.py
@@ -184,7 +184,11 @@ def item(
 
         return val
     elif isinstance(value, (list, tuple)):
-        if value and all(isinstance(v, dict) for v in value):
+        if (
+            value
+            and all(isinstance(v, dict) for v in value)
+            and (_parent is None or isinstance(_parent, Table))
+        ):
             a = AoT([])
             table_constructor = Table
         else:


Test patch:
diff --git a/tests/test_write.py b/tests/test_write.py
index 58752d9..9eb3e8a 100644
--- a/tests/test_write.py
+++ b/tests/test_write.py
@@ -17,3 +17,10 @@ def test_escape_special_characters_in_key():
     expected = '"foo\\nbar" = "baz"\n'
     assert expected == dumps(d)
     assert loads(dumps(d))["foo\nbar"] == "baz"
+
+
+def test_write_inline_table_in_nested_arrays():
+    d = {"foo": [[{"a": 1}]]}
+    expected = "foo = [[{a = 1}]]\n"  # noqa: FS003
+    assert expected == dumps(d)
+    assert loads(dumps(d))["foo"] == [[{"a": 1}]]