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:
Igor Ponomarev <igor.ponomarev@collabora.com>
Loading