Skip to content

Commit f150e09

Browse files
committed
Return Type Fixes for Valueless Config Entries
The `get_multivar` method accepts any key name — there is no multivar marker in the git config format. A valueless key can therefore appear among multivar results, so `__next__` on `ConfigMultivarIterator` returns `str | None`. Valueless keys are also returned as `None` by `__getitem__`.
1 parent a667f1f commit f150e09

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pygit2/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _next_entry(self) -> 'ConfigEntry':
7373

7474

7575
class ConfigMultivarIterator(ConfigIterator):
76-
def __next__(self) -> str: # type: ignore[override]
76+
def __next__(self) -> str | None: # type: ignore[override]
7777
entry = self._next_entry()
7878
return entry.value
7979

@@ -137,7 +137,7 @@ def __contains__(self, key: str | bytes) -> bool:
137137

138138
return True
139139

140-
def __getitem__(self, key: str | bytes) -> str:
140+
def __getitem__(self, key: str | bytes) -> str | None:
141141
"""
142142
When using the mapping interface, the value is returned as a string. In
143143
order to apply the git-config parsing rules, you can use

0 commit comments

Comments
 (0)