Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash 'Name' object has no attribute 'value' on airflow DAGs defined within a function #5448

Closed
boaz-codota opened this issue Dec 1, 2021 · 2 comments
Labels
Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint

Comments

@boaz-codota
Copy link

Bug description

""" creates team DAG """
import airflow
from airflow.models.dag import DAG
from airflow.operators.dummy import DummyOperator


def create_github_team_dag(dag_id: str, team_id: str):
    """
    Create Github Team DAG
    """
    dag = DAG(
        dag_id,
        schedule_interval="@daily",
        default_args={
            "depends_on_past": False,
            "email_on_failure": False,
            "email_on_retry": False,
        },
        start_date=airflow.utils.dates.days_ago(0),
        catchup=False,
    )

    with dag:
        DummyOperator(
            task_id="dummy",
        )

    return dag

pylint crashed with a AttributeError and with the following stacktrace:

Traceback (most recent call last):
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1034, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1069, in _check_file
    check_astroid_module(ast_node)
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1203, in check_astroid_module
    retval = self._check_astroid_module(
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1250, in _check_astroid_module
    walker.walk(node)
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint_airflow/checkers/dag.py", line 101, in visit_module
    dagid, dagnode = _find_dag(assign.value, func)
  File "/Users/--/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint_airflow/checkers/dag.py", line 93, in _find_dag
    return call_node.args[0].value, call_node
AttributeError: 'Name' object has no attribute 'value'

Configuration

No response

Command used

poetry run pylint --load-plugins=pylint_airflow dags/ tests/

Pylint output

Exception on node <Module.dags.tabnine.create_github_team_dag l.0 at 0x7ffdd92b15b0> in file '/Users/boazberman/Projects/Codota/airflow-dags/dags/tabnine/create_github_team_dag.py'
Traceback (most recent call last):
  File "/Users/boazberman/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/Users/boazberman/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint_airflow/checkers/dag.py", line 101, in visit_module
    dagid, dagnode = _find_dag(assign.value, func)
  File "/Users/boazberman/Projects/Codota/airflow-dags/.venv/lib/python3.8/site-packages/pylint_airflow/checkers/dag.py", line 93, in _find_dag
    return call_node.args[0].value, call_node
AttributeError: 'Name' object has no attribute 'value'
************* Module dags.tabnine.create_github_team_dag
dags/tabnine/create_github_team_dag.py:1:0: F0001: Fatal error while checking 'dags/tabnine/create_github_team_dag.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/boazberman/Library/Caches/pylint/pylint-crash-2021-12-01-10.txt'. (fatal)

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Expected behavior

It should not emit an exception

Pylint version

pylint 2.12.1
astroid 2.9.0
Python 3.8.8 (default, Apr 13 2021, 12:59:45) 
[Clang 10.0.0 ]

OS / Environment

Macbook Pro, 2019, Big Sur

Additional dependencies

[tool.poetry.dependencies]
python = "^3.8"
apache-airflow = { version = "2.1.4", extras = ["celery", "google", "slack", "docker", "cncf.kubernetes"] }

[tool.poetry.dev-dependencies]
flake8 = "^4.0.1"
flake8-black = "^0.2.3"
black = "^21.11b1"
pylint = "^2.12.1"
pylint-airflow = "^0.1.0-alpha.1"
pytest = "^6.2.5"

@boaz-codota boaz-codota added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 1, 2021
@DanielNoord
Copy link
Collaborator

Looking at the stacktrace this is actually a bug in another package called pylint-airflow. The crash occurs in their dag.py checker.

Could you please report this issue to their repository?

This issue already reported there might be related: BasPH/pylint-airflow#6

@DanielNoord DanielNoord added Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint and removed Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 1, 2021
@boaz-codota
Copy link
Author

Cool, thank you for the insanely fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint
Projects
None yet
Development

No branches or pull requests

2 participants