File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1515from tomlkit ._utils import _utc
1616from tomlkit .api import document
1717from tomlkit .exceptions import NonExistentKey
18+ from tomlkit .toml_document import TOMLDocument
1819
1920
2021def test_document_is_a_dict (example ):
@@ -1187,3 +1188,7 @@ def test_overwrite_out_of_order_table_key():
11871188
11881189"""
11891190 )
1191+
1192+
1193+ def test_set_default_int ():
1194+ TOMLDocument ().setdefault (4 , 5 )
Original file line number Diff line number Diff line change @@ -375,11 +375,15 @@ class SingleKey(Key):
375375
376376 def __init__ (
377377 self ,
378- k : str ,
378+ k : str | int ,
379379 t : KeyType | None = None ,
380380 sep : str | None = None ,
381381 original : str | None = None ,
382382 ) -> None :
383+ # keys are allowed to be ints but should be interpreted as strings
384+ if not isinstance (k , str ):
385+ k = str (k )
386+
383387 if t is None :
384388 if not k or any (
385389 c not in string .ascii_letters + string .digits + "-" + "_" for c in k
You can’t perform that action at this time.
0 commit comments