diff options
| author | Max Wittig <max.wittig@siemens.com> | 2021-04-20 08:58:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-20 08:58:30 +0200 |
| commit | 5b18d20f2f2bb71606892616f6c98ddc9d2ab836 (patch) | |
| tree | 0489a93e9b3a14cebc28a3e83699588c9a12103a /gitlab | |
| parent | fc4f7fd620ffc83acbc8ce531d0acb7ce4273763 (diff) | |
| parent | 8bd312404cf647674baea792547705ef1948043d (diff) | |
| download | gitlab-5b18d20f2f2bb71606892616f6c98ddc9d2ab836.tar.gz | |
Merge pull request #1398 from JohnVillalovos/jlvillal/mypy_mixins
fix: correct some type-hints in gitlab/mixins.py
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/mixins.py | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 9fce3da..3fa81ed 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -75,8 +75,8 @@ class GetMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -119,8 +119,8 @@ class GetWithoutIdMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -188,8 +188,8 @@ class ListMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -248,8 +248,8 @@ class RetrieveMixin(ListMixin, GetMixin): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -260,8 +260,8 @@ class CreateMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -328,8 +328,8 @@ class UpdateMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] _update_uses_post: bool = False gitlab: gitlab.Gitlab @@ -422,8 +422,8 @@ class SetMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -456,8 +456,8 @@ class DeleteMixin(_RestManagerBase): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -486,8 +486,8 @@ class CRUDMixin(GetMixin, ListMixin, CreateMixin, UpdateMixin, DeleteMixin): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -498,8 +498,8 @@ class NoUpdateMixin(GetMixin, ListMixin, CreateMixin, DeleteMixin): _computed_path: Optional[str] _from_parent_attrs: Dict[str, Any] _obj_cls: Optional[Type[base.RESTObject]] - _parent = Optional[base.RESTObject] - _parent_attrs = Dict[str, Any] + _parent: Optional[base.RESTObject] + _parent_attrs: Dict[str, Any] _path: Optional[str] gitlab: gitlab.Gitlab @@ -509,13 +509,12 @@ class NoUpdateMixin(GetMixin, ListMixin, CreateMixin, DeleteMixin): class SaveMixin(_RestObjectBase): """Mixin for RESTObject's that can be updated.""" - manager: UpdateMixin - _id_attr: Optional[str] _attrs: Dict[str, Any] _module: ModuleType _parent_attrs: Dict[str, Any] _updated_attrs: Dict[str, Any] + manager: base.RESTManager def _get_updated_data(self) -> Dict[str, Any]: updated_data = {} @@ -546,6 +545,8 @@ class SaveMixin(_RestObjectBase): # call the manager obj_id = self.get_id() + if TYPE_CHECKING: + assert isinstance(self.manager, UpdateMixin) server_data = self.manager.update(obj_id, updated_data, **kwargs) if server_data is not None: self._update_attrs(server_data) @@ -554,13 +555,12 @@ class SaveMixin(_RestObjectBase): class ObjectDeleteMixin(_RestObjectBase): """Mixin for RESTObject's that can be deleted.""" - manager: DeleteMixin - _id_attr: Optional[str] _attrs: Dict[str, Any] _module: ModuleType _parent_attrs: Dict[str, Any] _updated_attrs: Dict[str, Any] + manager: base.RESTManager def delete(self, **kwargs: Any) -> None: """Delete the object from the server. @@ -572,6 +572,8 @@ class ObjectDeleteMixin(_RestObjectBase): GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server cannot perform the request """ + if TYPE_CHECKING: + assert isinstance(self.manager, DeleteMixin) self.manager.delete(self.get_id()) |
