@@ -99,7 +99,7 @@ def _set_property(self, key: Union[str, List[str], IgnoreKey], value: Any) -> No
9999 if isinstance (value , list ):
100100 array = tomlkit .array ()
101101 array .extend (value )
102- array .multiline (True ) # Ensure consistent multiline formatting
102+ array .multiline (True )
103103 curr [key_path [- 1 ]] = array
104104 else :
105105 curr [key_path [- 1 ]] = value
@@ -222,7 +222,7 @@ def sync(self, metadata: ProjectMetadata) -> None:
222222 if field_value :
223223 # Create an inline array of tables
224224 inline_array = tomlkit .array ()
225- inline_array .multiline (False )
225+ inline_array .multiline (True )
226226
227227 # Convert each table to an inline table and add to array
228228 for item in field_value :
@@ -237,6 +237,7 @@ def sync(self, metadata: ProjectMetadata) -> None:
237237 # if license field has text, or file, make it inline table of tomlkit
238238 if self ._get_property (["license" ]) is not None :
239239 license_value = self ._get_property (["license" ])
240+ # Create and populate inline table
240241 inline_table = tomlkit .inline_table ()
241242 if isinstance (license_value , str ):
242243 inline_table ["text" ] = license_value
@@ -249,7 +250,23 @@ def sync(self, metadata: ProjectMetadata) -> None:
249250 inline_table ["text" ] = license_value .text
250251 elif hasattr (license_value , "file" ):
251252 inline_table ["file" ] = license_value .file
252- self ._set_property (["license" ], inline_table )
253+
254+ # Create a new table with the same structure
255+ table = tomlkit .table ()
256+ table .add ("license" , inline_table )
257+ if "license" in self ._data ["project" ]:
258+ # Copy the whitespace/formatting from the existing table
259+ table .trivia .indent = self ._data ["project" ]["license" ].trivia .indent
260+ table .trivia .comment_ws = self ._data ["project" ][
261+ "license"
262+ ].trivia .comment_ws
263+ table .trivia .comment = self ._data ["project" ][
264+ "license"
265+ ].trivia .comment
266+ table .trivia .trail = self ._data ["project" ]["license" ].trivia .trail
267+
268+ self ._data ["project" ]["license" ] = table ["license" ]
269+
253270 # Move urls section to the end if it exists
254271 if "urls" in self ._data ["project" ]:
255272 urls = self ._data ["project" ].pop ("urls" )
0 commit comments