Skip to content

Return type hint for SubsegmentContextManager.__enter__ in aws-xray-sdk should include None #13883

Closed
@allanlewis

Description

@allanlewis

The return type hint for SubsegmentContextManager.__enter__ is Subsegment, but the implementation can clearly return None. The type hint should therefore be Optional[Subsegment] or equivalent.

This has hit me when running tests on X-Ray-instrumented code, when there isn't a segment to derive from. I then end up with NREs as Mypy thinks that in_subsegment should have yielded a Subsegment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions