BasPH / pylint-airflow

Pylint plugin for static code analysis on Airflow code
MIT License
90 stars 13 forks source link

different-operator-varname-taskid doesn't handle a subclassed operator with a dynamic task_id #7

Open miketheman opened 3 years ago

miketheman commented 3 years ago

Example:

class AutoNameOperator(DummyOperator):
    def __init__(self, tbl_name):
        self.task_id = tbl_name.replace(".", "_")

    super().__init__(task_id=self.task_id)

eggs_spam = AutoNameOperator(tbl_name="eggs.spam")

I'd expect the evaluation of different-operator-varname-taskid to pass, however in this section:

https://github.com/BasPH/pylint-airflow/blob/95b976bbb3f42b7569464c65e5361faf77478b24/src/pylint_airflow/checkers/operator.py#L84-L93

task_id is None, and thereby raises the message.