MatrixManAtYrService opened a new issue #22665:
URL: https://github.com/apache/airflow/issues/22665
### Apache Airflow version
main (development)
### What happened
Here's a problematic dag. `False` is invalid here.
```python3
from airflow.models import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta
with DAG(
dag_id="singleton_expanded",
schedule_interval=timedelta(days=365),
start_date=datetime(2001, 1, 1),
) as dag:
# has problem
PythonOperator.partial(
task_id="foo",
python_callable=lambda x: "hi" if x else "bye",
).expand(op_args=False)
```
When I check for errors like `python dags/the_dag.py` I get the following
error:
```
Traceback (most recent call last):
File "/Users/matt/2022/03/30/dags/the_dag.py", line 13, in <module>
PythonOperator.partial(
File "/Users/matt/src/airflow/airflow/models/mappedoperator.py", line 187,
in expand
validate_mapping_kwargs(self.operator_class, "expand", mapped_kwargs)
File "/Users/matt/src/airflow/airflow/models/mappedoperator.py", line 116,
in validate_mapping_kwargs
raise ValueError(error)
ValueError: PythonOperator.expand() got an unexpected type 'bool' for
keyword argument op_args
Exception ignored in: <function OperatorPartial.__del__ at 0x10c63b1f0>
Traceback (most recent call last):
File "/Users/matt/src/airflow/airflow/models/mappedoperator.py", line 182,
in __del__
warnings.warn(f"{self!r} was never mapped!")
File
"/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/warnings.py",
line 109, in _showwarnmsg
sw(msg.message, msg.category, msg.filename, msg.lineno,
File "/Users/matt/src/airflow/airflow/settings.py", line 115, in
custom_show_warning
from rich.markup import escape
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 925, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1414, in find_spec
File "<frozen importlib._bootstrap_external>", line 1380, in _get_spec
TypeError: 'NoneType' object is not iterable
```
### What you think should happen instead
I'm not sure what's up with that type error, the ValueError is what I needed
to see. So I expected this:
```
Traceback (most recent call last):
File "/Users/matt/2022/03/30/dags/the_dag.py", line 13, in <module>
PythonOperator.partial(
File "/Users/matt/src/airflow/airflow/models/mappedoperator.py", line 187,
in expand
validate_mapping_kwargs(self.operator_class, "expand", mapped_kwargs)
File "/Users/matt/src/airflow/airflow/models/mappedoperator.py", line 116,
in validate_mapping_kwargs
raise ValueError(error)
ValueError: PythonOperator.expand() got an unexpected type 'bool' for
keyword argument op_args
```
### How to reproduce
_No response_
### Operating System
Mac OS
### Versions of Apache Airflow Providers
n/a
### Deployment
Virtualenv installation
### Deployment details
- cloned main at 327eab3e2
- created fresh venv and used pip to install
- `airflow info`
- `airflow db init`
- add the dag
- `python dags/the_dag.py`
### 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]