Recognize many=True serializer constructors as ListSerializer - #968
Recognize many=True serializer constructors as ListSerializer#968federicobond wants to merge 3 commits into
Conversation
b80ed88 to
8622fcc
Compare
|
Thanks! Sorry for the long delay in responding. This is a known issue, also documented at #827 Ideally, it would also be possible to express this with an overload of Problem is, right now mypy constrains the I'd prefer to avoid maintaining a mypy plugin if possible. Would you be up to implementing this in mypy instead? |
|
Will take a look and see what I can do! |
|
Great, thanks. If you see any reason why it wouldn't work then I can reconsider |
|
@federicobond Not sure if you're aware, the blocker was solved in mypy: python/mypy#21441 |
|
Amazing. I was not aware! |
I have made things!
At runtime,
SomeSerializer(many=True, ...)is swapped for a ListSerializer viamany_init, but the stubs type it as the original serializer, so valid calls are rejected and downstream attributes lie about their types.This adds a
get_function_signature_hookon every registered serializer class that, when many=True is literally passed: