@@ -35,6 +35,12 @@ def __init__(
3535 @property
3636 def authors (self ):
3737 """Return the only author of the package.json file as list."""
38+ # check if the author has the correct format
39+ if isinstance (author := self ._get_property (self ._get_key ("authors" )), str ):
40+ author = PackageJsonConfig .convert_author (author )
41+ if author is None :
42+ return []
43+
3844 return [self ._get_property (self ._get_key ("authors" ))]
3945
4046 @authors .setter
@@ -43,10 +49,49 @@ def authors(self, authors: List[Person]) -> None:
4349 authors = self ._from_person (authors [0 ])
4450 self ._set_property (self ._get_key ("authors" ), authors )
4551
52+ @property
53+ def maintainers (self ):
54+ """Return the maintainers of the package.json file."""
55+ # check if the maintainer has the correct format
56+ maintainers = self ._get_property (self ._get_key ("maintainers" ))
57+ # return empty list if maintainers is None
58+ if maintainers is None :
59+ return []
60+
61+ maintainers_valid = []
62+
63+ for maintainer in maintainers :
64+ if isinstance (maintainer , str ):
65+ maintainer = PackageJsonConfig .convert_author (maintainer )
66+ if maintainer is None :
67+ continue
68+ maintainers_valid .append (maintainer )
69+ return maintainers_valid
70+
71+ @maintainers .setter
72+ def maintainers (self , maintainers : List [Person ]) -> None :
73+ """Set the maintainers of the project."""
74+ maintainers = [self ._from_person (m ) for m in maintainers ]
75+ self ._set_property (self ._get_key ("maintainers" ), maintainers )
76+
4677 @property
4778 def contributors (self ):
4879 """Return the contributors of the package.json file."""
49- return self ._get_property (self ._get_key ("contributors" ))
80+ # check if the contributor has the correct format
81+ contributors = self ._get_property (self ._get_key ("contributors" ))
82+ # return empty list if contributors is None
83+ if contributors is None :
84+ return []
85+
86+ contributors_valid = []
87+
88+ for contributor in contributors :
89+ if isinstance (contributor , str ):
90+ contributor = PackageJsonConfig .convert_author (contributor )
91+ if contributor is None :
92+ continue
93+ contributors_valid .append (contributor )
94+ return contributors_valid
5095
5196 @contributors .setter
5297 def contributors (self , contributors : List [Person ]) -> None :
@@ -91,9 +136,12 @@ def _to_person(person) -> Person:
91136 """Convert package.json dict or str for person format to project metadata person object."""
92137 if isinstance (person , str ):
93138 # parse from package.json format
94- person = PackageJsonConfig .convert_author (person ).model_dump (
95- exclude_none = True
96- )
139+ person = PackageJsonConfig .convert_author (person )
140+
141+ if person is None :
142+ return None
143+
144+ person = person .model_dump (exclude_none = True )
97145
98146 names = list (map (lambda s : s .strip (), person ["name" ].split ()))
99147 person_obj = {
0 commit comments