diff options
author | John L. Villalovos <john@sodarock.com> | 2021-11-07 14:33:39 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2021-11-15 14:31:12 -0800 |
commit | 46773a82565cef231dc3391c12f296ac307cb95c (patch) | |
tree | 32cc9473ec28cc3d10be3baff28a74e8a17ac718 /gitlab/v4/objects/notes.py | |
parent | 94feb8a5534d43a464b717275846faa75783427e (diff) | |
download | gitlab-46773a82565cef231dc3391c12f296ac307cb95c.tar.gz |
chore: ensure get() methods have correct type-hintsjlvillal/mypy_ensure_type_hints
Fix classes which don't have correct 'get()' methods for classes
derived from GetMixin.
Add a unit test which verifies that classes have the correct return
type in their 'get()' method.
Diffstat (limited to 'gitlab/v4/objects/notes.py')
-rw-r--r-- | gitlab/v4/objects/notes.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gitlab/v4/objects/notes.py b/gitlab/v4/objects/notes.py index 9dd05cc..c4055ad 100644 --- a/gitlab/v4/objects/notes.py +++ b/gitlab/v4/objects/notes.py @@ -1,3 +1,5 @@ +from typing import Any, cast, Union + from gitlab.base import RequiredOptional, RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -46,6 +48,11 @@ class ProjectNoteManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectNote: + return cast(ProjectNote, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectCommitDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -69,6 +76,13 @@ class ProjectCommitDiscussionNoteManager( ) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectCommitDiscussionNote: + return cast( + ProjectCommitDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) + ) + class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectIssueNoteAwardEmojiManager @@ -81,6 +95,11 @@ class ProjectIssueNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectIssueNote: + return cast(ProjectIssueNote, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectIssueDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -101,6 +120,11 @@ class ProjectIssueDiscussionNoteManager( _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectIssueDiscussionNote: + return cast(ProjectIssueDiscussionNote, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectMergeRequestNoteAwardEmojiManager @@ -113,6 +137,11 @@ class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",)) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectMergeRequestNote: + return cast(ProjectMergeRequestNote, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectMergeRequestDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -134,6 +163,13 @@ class ProjectMergeRequestDiscussionNoteManager( _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectMergeRequestDiscussionNote: + return cast( + ProjectMergeRequestDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) + ) + class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectMergeRequestNoteAwardEmojiManager @@ -146,6 +182,11 @@ class ProjectSnippetNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",)) _update_attrs = RequiredOptional(required=("body",)) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectSnippetNote: + return cast(ProjectSnippetNote, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectSnippetDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -166,3 +207,10 @@ class ProjectSnippetDiscussionNoteManager( } _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) + + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectSnippetDiscussionNote: + return cast( + ProjectSnippetDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) + ) |