Skip to content

collect_traces wrong return type when it's used as a decorator #443

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

Closed
thepabloaguilar opened this issue Jun 27, 2020 · 0 comments · Fixed by #442
Closed

collect_traces wrong return type when it's used as a decorator #443

thepabloaguilar opened this issue Jun 27, 2020 · 0 comments · Fixed by #442
Labels
bug Something isn't working

Comments

@thepabloaguilar
Copy link
Member

We're using the @context_manager decorator on collect_traces function, so, we can use it as a decorator or context manager.
When we use it as a decorator, the decorated function be with a wrong return type!!

Type safety test:

- case: collect_traces_context_manager_return_type
  disable_cache: true
  main: |
    from returns.primitives.tracing import collect_traces

    @collect_traces
    def function() -> int:
      return 0

    reveal_type(function)  # N: Revealed type is 'def () -> builtins.int'

Expected:

Revealed type is 'def () -> builtins.int'

Actual:

Revealed type is 'contextlib._GeneratorContextManager[None]'

Refs #441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants