-
Notifications
You must be signed in to change notification settings - Fork 339
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
Enable mypy #362
Draft
gazpachoking
wants to merge
16
commits into
deluge-torrent:develop
Choose a base branch
from
gazpachoking:mypy_coroutine
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Enable mypy #362
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove type hints in docstrings in favor of the ones in method signatures.
Add a mypy config to pyproject.toml
Adds a custom stubs directory that defines twisted.internet.reactor for mypy. This prevents needing to cast the module in every file we want mypy to check.
# Conflicts: # deluge/core/core.py
Add pygobject-stubs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This isn't an actual pull request proposal yet, this was just playing around with getting mypy working, and I wanted a specific place to discuss mypy rather than in the other type hint ticket. This is on top of the current typing and maybe_coroutine PR branches, so diff has got more than just mypy fixes atm.
from __future__ import annotations
to make all the annotations just strings, so they don't have to actually run. If we do that, then we can run mypy on python 3.9+, where builtin types got type hinting support (dict
vstyping.Dict
) or even 3.10, where we got the pipe operator for union (str | int
vstyping.Union[str, int]
) I think both of those would go a long way towards readability, especially if we start using them to generate the autodocs for the api. I'm fairly certain that the invalid syntax of the type hints on python 3.7 and 3.8 won't matter as long as we do the docs generation and mypy on 3.10+ EDIT: After fixing up my other PRs, I realized we can achieve the same thing by just quotes around any syntaxes that aren't supported in older pythons.