uplsh580 opened a new issue #20646:
URL: https://github.com/apache/airflow/issues/20646
### Apache Airflow version
2.2.3 (latest released)
### What happened
To customize the operator, I inherited and customized the BashOperator.
It was used well in the previous 2.1.0 version without any problems, but an
error occurred in the 2.2.3 version as follows.
```
Broken DAG: [/opt/airflow/dags/test_dag_custom_operator.py] Traceback (most
recent call last):
File "/opt/airflow/dags/test_dag_custom_operator.py", line 14, in <module>
t1 = CustomOperator(task_id="date_task", cmd="date")
File
"/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py",
line 188, in apply_defaults
result = func(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'default_args'
```
### What you expected to happen
_No response_
### How to reproduce
create DAG file as below.
`custom_operator.py`
``` python
from airflow.operators.bash import BashOperator
class CustomOperator(BashOperator):
def __init__(self, task_id: str, cmd: str):
super().__init__(task_id=task_id, bash_command=cmd)
```
`custom_operator_dag.py`
``` python
from datetime import datetime, timedelta
from airflow import DAG
from custom_operator import CustomOperator
default_args = {"owner": "uplsh", "retries": 1, "retry_delay":
timedelta(minutes=1), "xcom_push_flag": True}
with DAG(
"custom_operator",
default_args=default_args,
description="A print date",
schedule_interval=timedelta(seconds=20),
start_date=datetime(2021, 1, 1),
catchup=False,
) as dag:
t1 = CustomOperator(task_id="date_task", cmd="date")
```
### Operating System
centos7.9, MacOS12.1 (It occurs in both environments.)
### Versions of Apache Airflow Providers
apache-airflow-providers-amazon | 2.4.0
apache-airflow-providers-celery | 2.1.0
apache-airflow-providers-cncf-kubernetes | 2.2.0
apache-airflow-providers-docker | 2.3.0
apache-airflow-providers-elasticsearch | 2.1.0
apache-airflow-providers-ftp | 2.0.1
apache-airflow-providers-google | 6.2.0
apache-airflow-providers-grpc | 2.0.1
apache-airflow-providers-hashicorp | 2.1.1
apache-airflow-providers-http | 2.0.1
apache-airflow-providers-imap | 2.0.1
apache-airflow-providers-microsoft-azure | 3.4.0
apache-airflow-providers-mysql | 2.1.1
apache-airflow-providers-odbc | 2.0.1
apache-airflow-providers-postgres | 2.4.0
apache-airflow-providers-redis | 2.0.1
apache-airflow-providers-sendgrid | 2.0.1
apache-airflow-providers-sftp | 2.3.0
apache-airflow-providers-slack | 4.1.0
apache-airflow-providers-sqlite | 2.0.1
apache-airflow-providers-ssh | 2.3.0
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]