Serializer inheritance not working correctly in pyright 1.1.309+
Functions declared in a custom serializer base class are not detected correctly and are flagged by pyright.
A simple example is:
from rest_framework import serializers
class RequestSerializer(serializers.Serializer):
def do_something(self):
print("did something")
class MySerializer(RequestSerializer):
pass
MySerializer().do_something()
Then running pyright on this code I get:
❯ pyright
/Users/rconyers/dev/pyright-inheritance-test/test.py
/Users/rconyers/dev/pyright-inheritance-test/test.py:10:16 - error: Cannot access member "do_something" for type "BaseSerializer"
Member "do_something" is unknown (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
However, running the code yields:
❯ python test.py
did something
So it seems like Python is able to successfully resolve the function, but the types are incorrect and are breaking static analysis.
I am using the following dependencies for this minimal reproducible example:
python = "^3.11"
pyright = "^1.1.310"
djangorestframework = "^3.14.0"
djangorestframework-types = "^0.8.0"
The error is not flagged in pyright 1.1.308 but it is flagged in 1.1.309.
The top line of pyright 1.1.309's release notes states:
Behavior Change: Reworked the logic for constructor type analysis to better mirror runtime behaviors of the type.call method. This is a big change with a potential for regressions.