ferruzzi commented on issue #21808:
URL: https://github.com/apache/airflow/issues/21808#issuecomment-1058924049
The problem is that the individual operators also declare the aws_conn
without a default value so it isn't optional, and it won't fall back to that
value:
```
In [1]: class Foo():
...: def __init__(self, myvar=5):
...: self.myvar = myvar
...:
...: def op(self):
...: return self.myvar
...:
...: class Bar(Foo):
...: def __init__(self, myvar):
...: super().__init__(myvar=myvar)
...:
In [2]: Foo().op()
Out[2]: 5
In [3]: Foo(3).op()
Out[3]: 3
In [4]: Bar(2).op()
Out[4]: 2
In [5]: Bar().op()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-06b11a1ebf4e> in <module>
----> 1 Bar().op()
TypeError: __init__() missing 1 required positional argument: 'myvar'
```
So if we move the defaulting into the child Operators, we don't have to
declare `aws_conn_id='default_aws'` in every operator use:
```
In [1]: class Foo:
...: def __init__(self):
...: pass
...:
...: def op(self):
...: return self.myvar
...:
...:
...: class Bar(Foo):
...: def __init__(self, myvar=5):
...: self.myvar = myvar
...: super().__init__()
...:
In [2]: Bar(2).op()
Out[2]: 2
In [3]: Bar().op()
Out[3]: 5
```
--
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]