uranusjr commented on code in PR #33423:
URL: https://github.com/apache/airflow/pull/33423#discussion_r1295279424
##########
airflow/cli/cli_parser.py:
##########
@@ -65,6 +65,22 @@
ALL_COMMANDS_DICT: dict[str, CLICommand] = {sp.name: sp for sp in
airflow_commands}
+# Check if sub-commands are defined twice, which could be an issue.
+if len(ALL_COMMANDS_DICT) < len(airflow_commands):
+ seen = set()
+ dup = []
+ for command in airflow_commands:
+ if command.name not in seen:
+ seen.add(command.name)
+ else:
+ dup.append(command.name)
+ log.warning(
+ "The following CLI %d command(s) are defined more than once, "
+ "CLI behavior when using those will be unpredictable: %s",
+ len(dup),
+ dup,
+ )
Review Comment:
I would do something like
```python
import collection
dups = {k for k, v in collection.Counter(airflow_commands).items() if v > 1}
log.warning(
"The following CLI command(s) are defined more than once, "
"CLI behavior when using those will be unpredictable: %s",
sorted(dups),
)
```
##########
airflow/cli/cli_parser.py:
##########
@@ -65,6 +65,22 @@
ALL_COMMANDS_DICT: dict[str, CLICommand] = {sp.name: sp for sp in
airflow_commands}
+# Check if sub-commands are defined twice, which could be an issue.
+if len(ALL_COMMANDS_DICT) < len(airflow_commands):
+ seen = set()
+ dup = []
+ for command in airflow_commands:
+ if command.name not in seen:
+ seen.add(command.name)
+ else:
+ dup.append(command.name)
+ log.warning(
+ "The following CLI %d command(s) are defined more than once, "
+ "CLI behavior when using those will be unpredictable: %s",
+ len(dup),
+ dup,
+ )
Review Comment:
I would do something like
```python
import collections
dups = {k for k, v in collections.Counter(airflow_commands).items() if v > 1}
log.warning(
"The following CLI command(s) are defined more than once, "
"CLI behavior when using those will be unpredictable: %s",
sorted(dups),
)
```
--
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]