Skip to content

BaseSegment defines put_annotation as having return type NoReturn #2002

Closed

Description

@tibbe

Expected Behaviour

The return type should be None. NoReturn means that the function never returns (e.g. it always throws an exception) and makes type checkers (e.g. mypy) mark all code following put_annotation as unreachable.

Also applies to put_metadata, patch, and patch_all.

Current Behaviour

These methods breaks type checking in any modules they're used because all code following a call to e.g. put_annotation is marked as unreachable.

Code snippet

with Tracer().provider.in_subsegment('test') as subsegment:
    subsegment.put_metadata('x', 1)
    print("hi")  # marked as unreachable

Possible Solution

Change the return type to None.

Steps to Reproduce

Use the code snippet above and run mypy on the file.

AWS Lambda Powertools for Python version

latest

AWS Lambda function runtime

3.9

Packaging format used

PyPi

Debugging logs

No response

Activity

  1. added
    bugSomething isn't working
    triagePending triage from maintainers
    on Mar 13, 2023
  2. heitorlessa commented on Mar 13, 2023

    @heitorlessa
    Contributor
  3. self-assigned this
    on Mar 13, 2023
  4. added
    pending-releaseFix or implementation already in dev waiting to be released
    and removed
    triagePending triage from maintainers
    on Mar 16, 2023
  5. github-actions commented on Mar 17, 2023

    @github-actions
    Contributor

    This is now released under 2.10.0 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions