Skip to content

BaseSegment defines put_annotation as having return type NoReturn #2002

Closed
@tibbe

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

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