@@ -70,21 +70,8 @@ def save(self, path: Optional[Path] = None) -> None:
7070 tomlkit .dump (self ._data , f )
7171 return
7272
73- with open (path , "r" ) as f :
74- # tomlkit formatting sometimes creates empty lines, dont change if context is not changed
75- existing_data = f .read ()
76-
77- # remove empty lines
78- existing_data = existing_data .replace ("\n " , "" )
79-
80- new_data = tomlkit .dumps (self ._data )
81- new_data = new_data .replace ("\n " , "" )
82-
83- if existing_data != new_data :
84- with open (path , "w" ) as f :
85- tomlkit .dump (self ._data , f )
86- else :
87- logger .debug ("No changes to pyproject.toml file" )
73+ with open (path , "w" ) as f :
74+ tomlkit .dump (self ._data , f )
8875
8976 def _get_property (
9077 self , key : Union [str , List [str ]], * , remove : bool = False , ** kwargs
@@ -235,39 +222,11 @@ def sync(self, metadata: ProjectMetadata) -> None:
235222
236223 # For Poetry v2, convert authors and maintainers from array of tables to inline tables
237224 if self ._poetry_version == 2 :
238- # if license field has text, or file, make it inline table of tomlkit
239- if self ._get_property (["license" ]) is not None :
240- license_value = self ._get_property (["license" ])
241- # Create and populate inline table
242- inline_table = tomlkit .inline_table ()
243- if isinstance (license_value , str ):
244- inline_table ["text" ] = license_value
245- elif isinstance (license_value , dict ):
246- if "text" in license_value :
247- inline_table ["text" ] = license_value ["text" ]
248- elif "file" in license_value :
249- inline_table ["file" ] = license_value ["file" ]
250- elif hasattr (license_value , "text" ):
251- inline_table ["text" ] = license_value .text
252- elif hasattr (license_value , "file" ):
253- inline_table ["file" ] = license_value .file
254-
255- # Create a new table with the same structure
256- table = tomlkit .table ()
257- table .add ("license" , inline_table )
258- if "license" in self ._data ["project" ]:
259- # Copy the whitespace/formatting from the existing table
260- table .trivia .indent = self ._data ["project" ]["license" ].trivia .indent
261- table .trivia .comment_ws = self ._data ["project" ][
262- "license"
263- ].trivia .comment_ws
264- table .trivia .comment = self ._data ["project" ][
265- "license"
266- ].trivia .comment
267- table .trivia .trail = self ._data ["project" ]["license" ].trivia .trail
268-
269- self ._data ["project" ]["license" ] = table ["license" ]
270-
225+ if "description" in self ._data ["project" ]:
226+ if "\n " in self ._data ["project" ]["description" ]:
227+ self ._data ["project" ]["description" ] = tomlkit .string (
228+ self ._data ["project" ]["description" ], multiline = True
229+ )
271230 # Move urls section to the end if it exists
272231 if "urls" in self ._data ["project" ]:
273232 urls = self ._data ["project" ].pop ("urls" )
0 commit comments