Skip to content
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

Merged
merged 4 commits into from
May 25, 2021
Merged

Improve static type checking #225

merged 4 commits into from
May 25, 2021

Conversation

kibablu
Copy link
Contributor

@kibablu kibablu commented May 24, 2021

Add type annotation to is_too_long Function on apnstruncate.py file
as part of the #201 issue

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]>
@@ -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:
Copy link
Contributor

@babolivier babolivier May 25, 2021

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]).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on it, Thank you :)

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 👇
dict
I'm running python 3.8

def is_too_long(payload: dict, max_length: int = 2048) -> bool:

@babolivier
Copy link
Contributor

Thanks for your contribution! :)

@babolivier babolivier merged commit 656c0ea into matrix-org:main May 25, 2021
@kibablu kibablu deleted the istoolongFunction branch May 26, 2021 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants