-
Notifications
You must be signed in to change notification settings - Fork 148
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
Improve static type checking #225
Conversation
Add type annotation to is_too_long Function on apnstruncate.py file as part of #201 issue Signed-off-by: Omar Mohamed <[email protected]>
as part of #201 issue Signed-off-by: Omar Mohamed <[email protected]>
sygnal/apnstruncate.py
Outdated
@@ -26,7 +26,7 @@ class BodyTooLongException(Exception): | |||
pass | |||
|
|||
|
|||
def is_too_long(payload, max_length=2048): | |||
def is_too_long(payload: Dict[Any, Any], max_length: int = 2048) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the type annotation you want is dict
here (instead of Dict[Any, Any]
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on it, Thank you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you've changed that with 8ae8f52 you'll also want to remove the import to typing.Dict
on line 18 since it's not used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I have just removed it after seeing my test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@babolivier is there a difference between typing.Dict
and dict
on python versions?
while running mypy --strict sygnal/ tests/ setup.py
I'm getting an error 👇
I'm running python 3.8
Line 29 in 656c0ea
def is_too_long(payload: dict, max_length: int = 2048) -> bool: |
Signed-off-by: Omar Mohamed <[email protected]>
Signed-off-by: Omar Mohamed <[email protected]>
Thanks for your contribution! :) |
Add type annotation to is_too_long Function on apnstruncate.py file
as part of the #201 issue