99from rich .pretty import pretty_repr
1010from tomlkit import load
1111
12- from somesy .core .models import Person
12+ from somesy .core .models import Person , ProjectMetadata
1313from somesy .core .writer import ProjectMetadataWriter
1414
1515from .models import PoetryConfig , SetuptoolsConfig
@@ -122,6 +122,7 @@ def __init__(self, path: Path):
122122 mappings = {
123123 "homepage" : ["urls" , "homepage" ],
124124 "repository" : ["urls" , "repository" ],
125+ "license" : ["license" , "text" ],
125126 }
126127 super ().__init__ (
127128 path , section = section , direct_mappings = mappings , model_cls = SetuptoolsConfig
@@ -146,6 +147,19 @@ def _to_person(person_obj) -> Person:
146147 }
147148 )
148149
150+ def sync (self , metadata : ProjectMetadata ) -> None :
151+ """Sync metadata with pyproject.toml file and fix license field."""
152+ super ().sync (metadata )
153+
154+ # if license field has both text and file, remove file
155+ if (
156+ self ._get_property (["license" , "file" ]) is not None
157+ and self ._get_property (["license" , "text" ]) is not None
158+ ):
159+ # delete license file property
160+ self ._data ["project" ]["license" ].pop ("file" )
161+ logger .debug ("Removed license file from pyproject.toml" )
162+
149163
150164# ----
151165
0 commit comments