Closed last-partizan closed 1 year ago
Update: we removed MongoQuerySet support from djangorestframework types and now this is ready to merge. It's working as expected with latest pyright.
@carltongibson can we merge this? or maybe you have some suggestions for improvements?
Hi. TBH I'm not keen on the inline annotations here. It seems like a lot of noise. 🤔
Could you use a stub file?
(Didn't I read they changed the Optional
syntax?)
Yes, new Optional and Union syntax available starting from Python 3.10, but probably we can use it with from __future__
import.
I've cleaned up it a bit and updated to use new syntax.
I theory, yes, i can use type stub - but it would require me to maintain separate package which will break if anything changed here.
It may seem as noise at first, and typing in python has some rough edges, but developer expirience is improved when we have types. I'm started adding types to my projects a few years ago, and it helped me to catch a few bugs.
That's especially useful when types are added to projects, not as separate stub files.
Nothing is going to change here 😅
Oh, okay.
@carltongibson btw, are you completely opposed to having types in the project, or just don't like the idea of types being in the same file?
I can refactor this to use separate .pyi
, so it won't pollute code file, but types still be accessible.
Hi @last-partizan -- good hustle 😜
I'm not totally opposed to the idea of the stub file...
My concerns would be:
I'd lean towards you just adding a stub file in your own project to begin, but if you want to open an exploratory PR here, I'm happy to look at that (and I would do so with an open mind.)
Hope that makes sense.
Yeah, maintaining separate type files is a fuss, that's why i like types in a code.
And maintaining my own stub files is yet bigger fuss.
I'd probably just use my fork with types, it would be easier to maintain in case of changes.
Have a nice day!
After recent changes to pyright, we need to add proper types for django-filters for it to pass type-checking.
Required changes is only
filter_queryset
types, but i have added other as well.This is draft, and it still not working as expected, but i will update this and djangoresframework-types after some discussion in pyright repo, on how to do this better.Main problem is thatdjangorestframework-types
have included MongoQuerySet in it's types, and i don't want to drag it here. Maybe it's better to replace it with some sort protocol there.