Skip to content

Commit 742e0a6

Browse files
committed
fix having maintainers field
1 parent 623eb5a commit 742e0a6

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/somesy/rust/writer.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from tomlkit import dump, load, table
88

99
from somesy.core.models import Person, ProjectMetadata
10-
from somesy.core.writer import IgnoreKey, ProjectMetadataWriter
10+
from somesy.core.writer import FieldKeyMapping, IgnoreKey, ProjectMetadataWriter
1111

1212
from .models import RustConfig, check_keyword
1313

@@ -17,15 +17,16 @@
1717
class Rust(ProjectMetadataWriter):
1818
"""Rust config file handler parsed from Cargo.toml."""
1919

20-
def __init__(self, path: Path, *, direct_mappings=None):
20+
def __init__(self, path: Path):
2121
"""Rust config file handler parsed from Cargo.toml.
2222
2323
See [somesy.core.writer.ProjectMetadataWriter.__init__][].
2424
"""
2525
self._section = ["package"]
26-
super().__init__(
27-
path, create_if_not_exists=False, direct_mappings=direct_mappings or {}
28-
)
26+
mappings: FieldKeyMapping = {
27+
"maintainers": IgnoreKey(),
28+
}
29+
super().__init__(path, create_if_not_exists=False, direct_mappings=mappings)
2930

3031
def _load(self) -> None:
3132
"""Load Cargo.toml file."""
@@ -51,9 +52,11 @@ def save(self, path: Optional[Path] = None) -> None:
5152
dump(self._data, f)
5253

5354
def _get_property(
54-
self, key: Union[str, List[str]], *, remove: bool = False, **kwargs
55+
self, key: Union[str, List[str], IgnoreKey], *, remove: bool = False, **kwargs
5556
) -> Optional[Any]:
5657
"""Get a property from the Cargo.toml file."""
58+
if isinstance(key, IgnoreKey):
59+
return None
5760
key_path = [key] if isinstance(key, str) else key
5861
full_path = self._section + key_path
5962
return super()._get_property(full_path, remove=remove, **kwargs)

tests/output/test_rust_writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def test_person_merge(rust_file, person):
118118
pj.sync(pm)
119119
pj.save()
120120

121-
assert len(pj.maintainers) == 1
122121
assert pj.authors[0] == person1c_rep
123122
assert pj.authors[1] == person3_rep
124123

0 commit comments

Comments
 (0)