-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add type hints #70
Add type hints #70
Conversation
Minimum allowed coverage is Generated by 🐒 cobertura-action against 699ff12 |
bananas/__init__.py
Outdated
@@ -1,25 +1,23 @@ | |||
VERSION = (2, 0, 0, "final", 0) | |||
|
|||
|
|||
def get_version(version=None): | |||
def get_version() -> str: |
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.
Felt unnecessary to implement types for version: Union[VersionTuple, str, None]
here instead of just dropping the version
argument and always use VERSION
.
bananas/models.py
Outdated
class Missing: | ||
... | ||
|
||
class ModelDict(dict): | ||
|
||
_nested = None | ||
MISSING: Final = Missing() |
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.
It's impossible to narrow the type of MISSING: Final = object()
, hence introducing a type here.
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.
Nice!
bananas.__init__
show_urls
commandsyncpermissions
commandbananas.models
Remaining untyped after this PR is
bananas.admin
andbananas.query
.I started working on
bananas.query
too, but that it'll take some amount of work to finish and gets very involved (probably impossible to achieve an acceptable level of typing without importing types from django-stubs, guarded byif TYPE_CHECKING
.