False Warning: "Unexpected argument" when using python multiple inheritance.

Hello. My Pycharm version is 2021.1.3

An "Unexpected argument" warning occurs during Python multiple inheritance usage.

Is this Pycharm error?

class TestParentClass(object):
def __init__(self, *args, **kwargs):
pass


def ReturnClass(*args, **kwargs):
return TestParentClass()


testParentClass: TestParentClass = ReturnClass()


class TestMixin(object):
pass


class TestClass(TestParentClass, TestMixin): # class TestClass(TestMixin, TestParentClass): both
pass


b = TestClass(b=10) # There is no warning.

 

class TestParentClass(object):
def __init__(self, *args, **kwargs):
pass


def ReturnClass(*args, **kwargs) -> TestParentClass:
return TestParentClass()


testParentClass: TestParentClass = ReturnClass()


class TestMixin(object):
pass


class TestClass(testParentClass, TestMixin): # class TestClass(TestMixin, testParentClass) both
pass


b = TestClass(b=10) # Unexpected argument

 

class TestParentClass(object):
def __init__(self, *args, **kwargs):
pass


def ReturnClass(*args, **kwargs) -> TestParentClass:
return TestParentClass()


testParentClass: TestParentClass = ReturnClass()


class TestMixin(object):
def __init__(self, *args, **kwargs):
pass
pass


class TestClass(TestMixin, testParentClass): # class TestClass(testParentClass, TestMixin) both
pass


b = TestClass(b=10) # There is no warning

I understand that using Python Mixin does not define __init__. However, to remove this warning, I need to define __init__.

Is this a bug? Or does it work normally?

This issue was observed when defining a table using "from sqlalchemy.ext.declarative import descriptive_base" and mixin in SQLAlchemy.

Thank you.

Please sign in to leave a comment.