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

annotate return types of a few functions to enable more mypy check #2702

Merged
merged 2 commits into from
May 5, 2024

Conversation

tdadela
Copy link
Contributor

@tdadela tdadela commented May 5, 2024

Before (mypy checks in CI):

mypy: commands[0]> mypy locust/
locust/stats.py:209: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/stats.py:210: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/runners.py:600: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/runners.py:661: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/runners.py:663: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/runners.py:681: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/contrib/fasthttp.py:345: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/main.py:94: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/test/test_runners.py:947: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]

After:

mypy: commands[0]> mypy locust/
locust/stats.py:209: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/stats.py:210: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/main.py:94: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
locust/test/test_runners.py:947: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]

The remaining 4 mypy notes requires more changes than just adding return types. (Fixing annotations inside functions.)

@cyberw
Copy link
Collaborator

cyberw commented May 5, 2024

👍 I’m considering switching to pyright. Do you have any opinion on that? Because it is so much faster it can be added as a precommit hook as well.

@cyberw cyberw merged commit e290263 into locustio:master May 5, 2024
14 checks passed
@tdadela tdadela deleted the annotate_a_few_functions branch May 5, 2024 21:16
@tdadela
Copy link
Contributor Author

tdadela commented May 5, 2024

My experience with both of them is limited, so unfortunately I can't share any useful thoughts.

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.

None yet

2 participants