Commit 36d9b24f authored by Igor Ponomarev's avatar Igor Ponomarev Committed by Nejc Habjan
Browse files

feat(api): Narrow down return type of ProjectFileManager.raw using typing.overload



This is equivalent to the changes in 44fd9dc1
but for `ProjectFileManager.raw` method that I must have missed
in the original commit.

Signed-off-by: default avatarIgor Ponomarev <igor.ponomarev@collabora.com>
parent 175b355d
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@ from typing import (
    Dict,
    Iterator,
    List,
    Literal,
    Optional,
    overload,
    Tuple,
    TYPE_CHECKING,
    Union,
@@ -274,6 +276,45 @@ class ProjectFileManager(CreateMixin, UpdateMixin, DeleteMixin, RESTManager):
        data = {"branch": branch, "commit_message": commit_message}
        self.gitlab.http_delete(path, query_data=data, **kwargs)

    @overload
    def raw(
        self,
        file_path: str,
        ref: Optional[str] = None,
        streamed: Literal[False] = False,
        action: None = None,
        chunk_size: int = 1024,
        *,
        iterator: Literal[False] = False,
        **kwargs: Any,
    ) -> bytes: ...

    @overload
    def raw(
        self,
        file_path: str,
        ref: Optional[str] = None,
        streamed: bool = False,
        action: None = None,
        chunk_size: int = 1024,
        *,
        iterator: Literal[True] = True,
        **kwargs: Any,
    ) -> Iterator[Any]: ...

    @overload
    def raw(
        self,
        file_path: str,
        ref: Optional[str] = None,
        streamed: Literal[True] = True,
        action: Optional[Callable[[bytes], None]] = None,
        chunk_size: int = 1024,
        *,
        iterator: Literal[False] = False,
        **kwargs: Any,
    ) -> None: ...

    @cli.register_custom_action(
        cls_names="ProjectFileManager",
        required=("file_path",),