Open last-partizan opened 1 year ago
We should add mypy
to the CI to verify types, before to officially support type hints.
If you’re up for it, that would be greatly appreciated!
Sure, but first, some questions.
mypy
specifically, or pyright
is fine too? I'm more used to pyright, and it has nice --outputjson
option, so we can test against snapshot as in my linked PR.Currently, pyright has better type-checking capabilities, here's example run on this package.
But, if we're planning to only verify that after adding types - we're getting what we expecting - both are good choices.
https://github.com/stefanfoulis/django-phonenumber-field/pull/563
Here's basic mypy integration, and it already passes the tests with only two minor changes.
That’s great, thanks! :star:
pyright
look like false positives, not issues of interest. I would rather stick with mypy
, since that’s what Django might be using in the future according to https://github.com/django/deps/pull/65/, and the target of django-stubs.Now the hard part!
I'll try to add types for fields, my previous idea was working with pyright but i'll need to do some changes for mypy :)
What's preferred way of adding types, inline or in separate .pyi
files?
I vote for inline, they provide information when reading the source that way, without having to jump back and forth between the .pyi or relying on IDE support.
Any update? PR not merged yet.
Hi, are you interested in adding typing support to your project?
Right now with latest pyright and django-types field in a model behaves like
str
, becouse it's based on CharField.To fix this, i'm using
.pyi
with following content locally:I can make a PR with a changes if you're interested.