eladkal opened a new issue, #49875:
URL: https://github.com/apache/airflow/issues/49875

   ### Body
   
   Given code:
   
   ```
   from datetime import datetime
   from airflow import DAG
   from airflow.decorators import task
   from time import sleep
   
   default_args = {
       'owner': 'airflow',
       'start_date': datetime(2023, 2, 1)
   }
   
   
   with DAG('scheduler', schedule="@daily", catchup=True, 
default_args=default_args):
   
       @task()
       def sleep():
           sleep(3600)
       sleep()
   ```
   
   It fails with:
   
   ```
   TypeError: too many positional arguments
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 829 in run
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 1092 in _execute_task
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 408 in 
wrapper
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 251 in 
execute
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 408 in 
wrapper
   
   File 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
 line 212 in execute
   
   File 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
 line 235 in execute_callable
   
   File 
"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/callback_runner.py", line 
81 in run
   
   File "/files/dags/scheduler.py", line 15 in sleep
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 363 in 
__call__
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 513 in 
apply_defaults
   
   File 
"/opt/airflow/providers/standard/src/airflow/providers/standard/decorators/python.py",
 line 58 in __init__
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 513 in 
apply_defaults
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 239 in 
__init__
   
   File "/usr/local/lib/python3.9/inspect.py", line 3045 in bind
   
   File "/usr/local/lib/python3.9/inspect.py", line 2966 in _bind
   
   ```
   
   
   The reason for this failure is because the python task has the exact name as 
the python function it executes thus Airflow thinks it's recursion. Obviously 
this is wrong coding but I expected the error to be more informative. I think 
we need to catch this case and raise user friendly error. My real code was more 
complex than the example I share here.. it took me several minutes to figure 
out what was the issue.
   
   <img width="1610" alt="Image" 
src="https://github.com/user-attachments/assets/6d56a97f-fc77-4743-913a-d34b16654bb0";
 />
   
   ### Committer
   
   - [x] I acknowledge that I am a maintainer/committer of the Apache Airflow 
project.


-- 
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]

Reply via email to