pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

False `unexpected-keyword` on constructor when the first base class is written as `class Mixin(object)`

Open aduernberger opened this issue 1 month ago • 1 comments

Describe the Bug

We use django with django-ldapdb.

Error Unexpected keyword argument `db_column` in function `object.__init__`Pyrefly[unexpected-keyword]

We see the error in the following case (or just check the sandbox link, with a minimal case).

# our code
IntegerField(db_column='test')

# django-ldapdb
class LdapFieldMixin(object): ...
class IntegerField(LdapFieldMixin, fields.IntegerField): ...

# Django
class Field(RegisterLookupMixin):
    def __init__(self, ..., db_column=None, ...): ...
class IntegerField(Field): ...

The error vanishes if we replace class LdapFieldMixin(object): with class LdapFieldMixin:

Tested with 1.3.2 and 1.4.0-dev.3, python 3.12. ty, zuban and basedpyright work correctly here.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.w1VkQrKKUyI8wrHkkworYAyUAJ1lgDOTVABlK0BxBst8vpkVwGiEZgiUiECocdYAq9IBW4-pyFmjwtZQEzP4lRUCIAIKUJ8ACx5gvKWXAos3YHzoxeQpA0u2VIWMkpKCYit9fZj2_KJ0_dQ8_ZT85GJ9FB36CqCUlliWmAkuNFGNU8gHJ5dioLGUxLs6JNrV8cW6OijSgSrwRiQA

(Only applicable for extension issues) IDE Information

No response

aduernberger avatar Oct 13 '26 14:10 aduernberger

Thanks for the report and the minimal repro! Pyrefly puts an explicit object base ahead of the other bases when it works out the class's MRO, so C(x=1) gets checked against object.__init__. This sandbox shows it next to the plain class Mixin: version: https://pyrefly.org/sandbox/?project=v2.q8ZRZEKyilNiMZ58UmEFjIESoLMMcGaSCqBsBSjOYJnPN7MCGI3QDIESEQg1ATlAn4EV4lDgrAGW1QG7D5cpLhoIc3CpdNaosDXUVFBQVkitKADlJYXSPAgLEvLl-UXAgs0FQ1UeOCtVwfwPjJai_Lz0GCVkNUmJKbpAi4DRmpuaVwKMMXzRAAA

shahhamdihassan avatar Oct 15 '26 17:10 shahhamdihassan