@@ -96,61 +96,19 @@ def __init__(self, path: Path):
9696 """
9797 super ().__init__ (path , section = ["tool" , "poetry" ], model_cls = PoetryConfig )
9898
99- @property
100- def authors (self ) -> List [str ]:
101- """Get authors from the pyproject.toml file."""
102- # check if authors can be converted to person, only return valid ones
103- authors = self ._get_property ("authors" )
104- if authors is None :
105- return []
106-
107- valid_authors = []
108- for author in authors :
109- try :
110- self ._to_person (author )
111- valid_authors .append (author )
112- except (ValueError , AttributeError ):
113- logger .warning (f"Invalid author format: { author } " )
114- return valid_authors
115-
116- @authors .setter
117- def authors (self , authors : List [Person ]) -> None :
118- """Set the authors of the project."""
119- authors = [self ._from_person (c ) for c in authors ]
120- self ._set_property (self ._get_key ("authors" ), authors )
121-
122- @property
123- def maintainers (self ) -> List [str ]:
124- """Get maintainers from the pyproject.toml file."""
125- # check if maintainers can be converted to person, only return valid ones
126- maintainers = self ._get_property ("maintainers" )
127- if maintainers is None :
128- return []
129-
130- valid_maintainers = []
131- for maintainer in maintainers :
132- try :
133- self ._to_person (maintainer )
134- valid_maintainers .append (maintainer )
135- except (ValueError , AttributeError ):
136- logger .warning (f"Invalid maintainer format: { maintainer } " )
137- return valid_maintainers
138-
139- @maintainers .setter
140- def maintainers (self , maintainers : List [Person ]) -> None :
141- """Set the maintainers of the project."""
142- maintainers = [self ._from_person (c ) for c in maintainers ]
143- self ._set_property (self ._get_key ("maintainers" ), maintainers )
144-
14599 @staticmethod
146100 def _from_person (person : Person ):
147101 """Convert project metadata person object to poetry string for person format "full name <email>."""
148102 return person .to_name_email_string ()
149103
150104 @staticmethod
151- def _to_person (person_obj : str ) -> Person :
105+ def _to_person (person_obj : str ) -> Optional [ Person ] :
152106 """Parse poetry person string to a Person."""
153- return Person .from_name_email_string (person_obj )
107+ try :
108+ return Person .from_name_email_string (person_obj )
109+ except (ValueError , AttributeError ):
110+ logger .warning (f"Cannot convert { person_obj } to Person object." )
111+ return None
154112
155113
156114class SetupTools (PyprojectCommon ):
0 commit comments