Skip to content

Commit eb15123

Browse files
committed
Use cast to allow silent getattrs
1 parent b5c834a commit eb15123

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

git/util.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,9 +1214,7 @@ def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> T_Iterabl
12141214
raise ValueError("Index should be an int or str")
12151215
else:
12161216
try:
1217-
if not isinstance(index, str):
1218-
raise AttributeError(f"{index} is not a valid attribute")
1219-
return getattr(self, index)
1217+
return getattr(self, cast(str, index))
12201218
except AttributeError as e:
12211219
raise IndexError(f"No item found with id {self._prefix}{index}") from e
12221220
# END handle getattr

0 commit comments

Comments
 (0)