-
Notifications
You must be signed in to change notification settings - Fork 677
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
feat: adding typehints #683
Conversation
Regarding the tox configuration, I just noticed there were already talks about removing djmain and adding support for the drf3.14 in PR #623. |
Our API doesn't change that much, so adding mypy would be appreciated if time permits. Greatly appreciate this effort! |
Thanks again! I'm going to merge this for now, and then it would be great to have a separate mypy PR |
Sure thing! Will get started on adding mypy as pre-commit hook. I'm not sure however, how far we would want to go to make sure the mypy check also passes. I guess it also depends a bit on the configuration we use for mypy. But I can imagine we would still get some warnings out of it, which can either be ignored with Either way, I will start on it and see into which issues I'll be running. Thanks for approving the PR! |
Hi! I'd like to run this locally and take a look myself, as skimming trough I noticed some things that I think could be better typed; but I'm having trouble setting up a development environment to be able to run mypy trough. Do you have any guide / instructions on how you did it? |
Unfortunately mypy fails because it's missing django-stubs, which are not included or configured in the test package (I imagine they'd be getting in with the pre-commit hook @abczzz13 will work on). I'll try to setup a dummy project with everything setup and install the djangorestframework-simplejwt from there and run mypy against it. But if @abczzz13 has a better / simpler method, I'd be all ears. Edit: also, while at it, this should be developed against any specific Django / DRF / python versions? |
Hey Pedro! I can fully imagine it can be better typed, especially when taking into account myp with django and drf stubs. Any help on this would be welcome :) I made a beginning with adding mypy precommit hook, including the stubs, which indeed caused a whole bunch typing warnings which needed some working. Let me know if you want to see/use anything that I have, or that you will start with a blank slate. In the tox.ini file you can see all the specific versions it gets tested with. |
I'm happy to setup a clean "test" django repository, alongside my own fork of this repo where I do my own improvements on it. When it's ready, I'll link it here. I'll start from the latest master commits. |
Here is what I'll be using: |
What
Added typehints, as mentioned in #664.
Discussion
type: ignore
at a few places. Not sure if that’s something we would want, as it could also mask problems that might want to be tackled in the future.Issues related to the tox configuration
Not sure if that’s something we should worry about. It seems that djmain doesn’t play nice with drf3.13, which has been fixed in drf3.14.
Could possibly be picked up in a separate PR. Let me know what you think of it.
Tests
Did not create any additional tests, as I didn't expect it to be relevant for adding typehints. Made sure all existing tests still ran as expected (except for the above mentioned issues). Also tried to minimize the number of warnings from mypy, but was not able to fix all of them (would also depend on the mypy configuration).
Future…
Finally
Feedback/suggestions are welcome! Will happily make adjustments wherever necessary. :)