Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/batched_gather_return_exceptions #68

Merged
merged 3 commits into from
Apr 25, 2022

Conversation

giuliano-macedo
Copy link
Contributor

Fixes #66.

Qual o propósito deste pull request?

Adiciona parâmetro return_exceptions no batched_gather para o usuário ter um controle melhor das excessões quando usando essa função.
Também foi adicionado os @overload para ter um type checking retrocompativel e também condizente quando setando o return_exceptions = True.

Como esta mudança deve ser testada?

Testes unitários cobrem o uso em runtime, porém o teste de tipagem estática utilizando o mypy com o seguinte código, também testa essa PR:

reveal_type(batched_gather(sleep_and_return, [1,1,1], 2))
reveal_type(batched_gather(sleep_and_return, [1,1,1], 2, False))
reveal_type(batched_gather(sleep_and_return, [1,1,1], 2, True))

b:bool
reveal_type(batched_gather(sleep_and_return, [1,1,1], 2, b))

Resultado esperado:

note: Revealed type is "typing.AsyncIterator[builtins.list[builtins.float*]]"
note: Revealed type is "typing.AsyncIterator[builtins.list[builtins.float*]]"
note: Revealed type is "typing.AsyncIterator[builtins.list[Union[builtins.Exception, builtins.float*]]]"
note: Revealed type is "typing.AsyncIterator[builtins.list[builtins.float*]]"

Tipo das mudanças

  • Nova funcionalidade (mudança, sem quebra de contrato, que adiciona um nova funcionalidade)

@giuliano-macedo giuliano-macedo force-pushed the feat/batched_gather_return_exceptions branch from 1455a3d to 1c55798 Compare April 24, 2022 15:49
pass


async def batched_gather( # type: ignore[misc]
Copy link
Contributor Author

@giuliano-macedo giuliano-macedo Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this type: ignore because i was getting: Overloaded function implementation cannot produce return type of signature 2 and it doesn't make a lot of sense to me, it seems to be related to this bug, but I'm not sure.

@giuliano-macedo giuliano-macedo merged commit 7c0ec02 into main Apr 25, 2022
@giuliano-macedo giuliano-macedo deleted the feat/batched_gather_return_exceptions branch April 25, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Criar um return_exception no batched_gather
3 participants