diff options
author | John L. Villalovos <john@sodarock.com> | 2022-01-06 00:42:47 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2022-01-06 00:42:47 -0800 |
commit | 7555b3a663acdea99fab06baa23e48d335e7baec (patch) | |
tree | 25fe3834e8ae389cbcbd100d0817f7737ee3ad81 /gitlab/v4/objects/projects.py | |
parent | a349793307e3a975bb51f864b48e5e9825f70182 (diff) | |
download | gitlab-jlvillal/put_post_raw.tar.gz |
chore: correct type-hints for http_put/http_postjlvillal/put_post_raw
http_put/http_post will either return a JSON object or nothing. We
never expect them to return a raw requests.response object.
Update type-hints and code to no longer have a requests.response
object as a possible return value.
Diffstat (limited to 'gitlab/v4/objects/projects.py')
-rw-r--r-- | gitlab/v4/objects/projects.py | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 74671c8..7e0bfbe 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -244,8 +244,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO """ path = f"/projects/{self.get_id()}/star" server_data = self.manager.gitlab.http_post(path, **kwargs) - if TYPE_CHECKING: - assert isinstance(server_data, dict) self._update_attrs(server_data) @cli.register_custom_action("Project") @@ -262,8 +260,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO """ path = f"/projects/{self.get_id()}/unstar" server_data = self.manager.gitlab.http_post(path, **kwargs) - if TYPE_CHECKING: - assert isinstance(server_data, dict) self._update_attrs(server_data) @cli.register_custom_action("Project") @@ -280,8 +276,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO """ path = f"/projects/{self.get_id()}/archive" server_data = self.manager.gitlab.http_post(path, **kwargs) - if TYPE_CHECKING: - assert isinstance(server_data, dict) self._update_attrs(server_data) @cli.register_custom_action("Project") @@ -298,8 +292,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO """ path = f"/projects/{self.get_id()}/unarchive" server_data = self.manager.gitlab.http_post(path, **kwargs) - if TYPE_CHECKING: - assert isinstance(server_data, dict) self._update_attrs(server_data) @cli.register_custom_action( @@ -376,8 +368,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO path = f"/projects/{self.get_id()}/trigger/pipeline" post_data = {"ref": ref, "token": token, "variables": variables} attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) - if TYPE_CHECKING: - assert isinstance(attrs, dict) return ProjectPipeline(self.pipelines, attrs) @cli.register_custom_action("Project") @@ -444,9 +434,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO url = f"/projects/{self.id}/uploads" file_info = {"file": (filename, filedata)} data = self.manager.gitlab.http_post(url, files=file_info) - - if TYPE_CHECKING: - assert isinstance(data, dict) return {"alt": data["alt"], "url": data["url"], "markdown": data["markdown"]} @cli.register_custom_action("Project", optional=("wiki",)) @@ -526,7 +513,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO @cli.register_custom_action("Project", ("to_namespace",)) @exc.on_http_error(exc.GitlabTransferProjectError) - def transfer_project(self, to_namespace: str, **kwargs: Any) -> None: + def transfer_project(self, to_namespace: str, **kwargs: Any) -> Dict[str, Any]: """Transfer a project to the given namespace ID Args: @@ -539,7 +526,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO GitlabTransferProjectError: If the project could not be transferred """ path = f"/projects/{self.id}/transfer" - self.manager.gitlab.http_put( + return self.manager.gitlab.http_put( path, post_data={"namespace": to_namespace}, **kwargs ) @@ -811,7 +798,7 @@ class ProjectManager(CRUDMixin, RESTManager): overwrite: bool = False, override_params: Optional[Dict[str, Any]] = None, **kwargs: Any, - ) -> Union[Dict[str, Any], requests.Response]: + ) -> Dict[str, Any]: """Import a project from an archive file. Args: @@ -854,7 +841,7 @@ class ProjectManager(CRUDMixin, RESTManager): new_name: Optional[str] = None, target_namespace: Optional[str] = None, **kwargs: Any, - ) -> Union[Dict[str, Any], requests.Response]: + ) -> Dict[str, Any]: """Import a project from BitBucket Server to Gitlab (schedule the import) This method will return when an import operation has been safely queued, @@ -943,7 +930,7 @@ class ProjectManager(CRUDMixin, RESTManager): target_namespace: str, new_name: Optional[str] = None, **kwargs: Any, - ) -> Union[Dict[str, Any], requests.Response]: + ) -> Dict[str, Any]: """Import a project from Github to Gitlab (schedule the import) This method will return when an import operation has been safely queued, |