grihabor opened a new pull request, #41086:
URL: https://github.com/apache/airflow/pull/41086
Fixes #41085
Here is a small example to illustrate the problem:
```python
class InitMeta(type):
def __new__(cls, name, bases, namespace, **kwargs):
new_cls = super().__new__(cls, name, bases, namespace, **kwargs)
new_cls.__init__ = new_cls.__init__
return new_cls
class A(metaclass=InitMeta):
def __init__(self):
print("A")
super().__init__()
class B(A):
pass
class C(A):
def __init__(self):
print("C")
super().__init__()
class D(B, C):
pass
D()
```
This outputs:
```
A
```
But without metaclass the output is:
```
C
A
```
This happens because `B.__init__` was set to `A.__init__` at the B class
definition time, but this is not what MRO is doing.
To fix this, I propose patching `__init__` only if the class actually
defines it's own `__init__`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]