| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a1dbe86 commit 0c3a1d1
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ | |||
| 19 | 19 | import pprint | |
| 20 | 20 | import textwrap | |
| 21 | 21 | from types import ModuleType | |
| 22 | - from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type | ||
| 22 | + from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type, Union | ||
| 23 | 23 | ||
| 24 | 24 | import gitlab | |
| 25 | 25 | from gitlab import types as g_types | |
@@ -211,14 +211,14 @@ def _update_attrs(self, new_attrs: Dict[str, Any]) -> None: | |||
| 211 | 211 | self.__dict__["_updated_attrs"] = {} | |
| 212 | 212 | self.__dict__["_attrs"] = new_attrs | |
| 213 | 213 | ||
| 214 | - def get_id(self) -> Any: | ||
| 214 | + def get_id(self) -> Optional[Union[int, str]]: | ||
| 215 | 215 | """Returns the id of the resource.""" | |
| 216 | 216 | if self._id_attr is None or not hasattr(self, self._id_attr): | |
| 217 | 217 | return None | |
| 218 | 218 | return getattr(self, self._id_attr) | |
| 219 | 219 | ||
| 220 | 220 | @property | |
| 221 | - def encoded_id(self) -> Any: | ||
| 221 | + def encoded_id(self) -> Optional[Union[int, str]]: | ||
| 222 | 222 | """Ensure that the ID is url-encoded so that it can be safely used in a URL | |
| 223 | 223 | path""" | |
| 224 | 224 | obj_id = self.get_id() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -576,6 +576,7 @@ def delete(self, **kwargs: Any) -> None: | |||
| 576 | 576 | """ | |
| 577 | 577 | if TYPE_CHECKING: | |
| 578 | 578 | assert isinstance(self.manager, DeleteMixin) | |
| 579 | + assert self.encoded_id is not None | ||
| 579 | 580 | self.manager.delete(self.encoded_id, **kwargs) | |
| 580 | 581 | ||
| 581 | 582 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,8 @@ def delete( # type: ignore | |||
| 77 | 77 | GitlabDeleteError: If the server cannot perform the request | |
| 78 | 78 | """ | |
| 79 | 79 | file_path = self.encoded_id | |
| 80 | + if TYPE_CHECKING: | ||
| 81 | + assert isinstance(file_path, str) | ||
| 80 | 82 | self.manager.delete(file_path, branch, commit_message, **kwargs) | |
| 81 | 83 | ||
| 82 | 84 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments