| 1355 | |
| 1356 | # could be function, but must be able to reference as :class:`chain`. |
| 1357 | def __new__(cls, *tasks, **kwargs): |
| 1358 | # This forces `chain(X, Y, Z)` to work the same way as `X | Y | Z` |
| 1359 | if not kwargs and tasks: |
| 1360 | if len(tasks) != 1 or is_list(tasks[0]): |
| 1361 | tasks = tasks[0] if len(tasks) == 1 else tasks |
| 1362 | # if is_list(tasks) and len(tasks) == 1: |
| 1363 | # return super(chain, cls).__new__(cls, tasks, **kwargs) |
| 1364 | new_instance = reduce(operator.or_, tasks, _chain()) |
| 1365 | if cls != chain and isinstance(new_instance, _chain) and not isinstance(new_instance, cls): |
| 1366 | return super().__new__(cls, new_instance.tasks, **kwargs) |
| 1367 | return new_instance |
| 1368 | return super().__new__(cls, *tasks, **kwargs) |
| 1369 | |
| 1370 | |
| 1371 | class _basemap(Signature): |