-
Notifications
You must be signed in to change notification settings - Fork 429
BaseSegment
defines put_annotation
as having return type NoReturn
#2002
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
Labels
bug
Something isn't working
Comments
Thanks a lot for filling this Johan, definitely overlooked it. If you have
the bandwidth to make a PR, we can include it in the next release.
Thank you!
…On Mon, 13 Mar 2023 at 12:06, Johan Tibell ***@***.***> wrote:
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*
—
Reply to this email directly, view it on GitHub
<#2002>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBEEDTGLIBZ26P62YT3W335RRANCNFSM6AAAAAAVY5JAIM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
tibbe
added a commit
to tibbe/aws-lambda-powertools-python
that referenced
this issue
Mar 13, 2023
NoReturn are for methods that never return (e.g. always raise exceptions). Using NoReturn causes e.g. mypy to think all code following the call to the NoReturn method to be unreachable. Fixes aws-powertools#2002.
7 tasks
7 tasks
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
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 followingput_annotation
as unreachable.Also applies to
put_metadata
,patch
, andpatch_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
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
The text was updated successfully, but these errors were encountered: