Skip to content
Commit 44fd9dc1 authored by Igor Ponomarev's avatar Igor Ponomarev Committed by John Villalovos
Browse files

feat(api): Narrow down return type of download methods using typing.overload



Currently the download methods such as `ProjectJob.artifacts` have
return type set to `Optional[Union[bytes, Iterator[Any]]]` which
means they return either `None` or `bytes` or `Iterator[Any]`.

However, the actual return type is determined by the passed
`streamed` and `iterator` arguments. Using `@typing.overload`
decorator it is possible to return a single type based on the
passed arguments.

Add overloads in the following order to all download methods:

1. If `streamed=False` and `iterator=False` return `bytes`. This
   is the default argument values therefore it should be first as
   it will be used to lookup default arguments.
2. If `iterator=True` return `Iterator[Any]`. This can be combined
   with both `streamed=True` and `streamed=False`.
3. If `streamed=True` and `iterator=False` return `None`. In this
   case `action` argument can be set to a callable that accepts
   `bytes`.

Signed-off-by: default avatarIgor Ponomarev <igor.ponomarev@collabora.com>
parent e4c5c74f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment