gemini-code-assist[bot] commented on code in PR #36072:
URL: https://github.com/apache/beam/pull/36072#discussion_r2325856376
##########
sdks/python/apache_beam/options/pipeline_options.py:
##########
@@ -449,11 +450,31 @@ def from_dictionary(cls, options):
return cls(flags)
+ @staticmethod
+ def _warn_on_unknown_options(unknown_args, parser):
+ if not unknown_args:
+ return
+
+ all_known_options = [
+ opt for action in parser._actions for opt in action.option_strings
+ ]
+
+ for arg in unknown_args:
+ if not arg.startswith('--'):
+ continue
+ arg_name = arg.split('=', 1)[0]
+ suggestions = difflib.get_close_matches(arg_name, all_known_options)
+ msg = f"Unparseable argument: {arg}"
+ if suggestions:
+ msg += f". Did you mean '{suggestions[0]}'?"
+ _LOGGER.warning(msg)
Review Comment:

The current implementation only warns about unknown options that start with
`--`. This is a regression from the previous behavior, which would warn about
any unknown arguments, including short options (e.g., `-x`) and positional
arguments.
To ensure all unparseable arguments are reported to the user, I suggest
modifying the loop to warn for all unknown arguments, while still providing
suggestions only for long options.
```suggestion
for arg in unknown_args:
msg = f"Unparseable argument: {arg}"
if arg.startswith('--'):
arg_name = arg.split('=', 1)[0]
suggestions = difflib.get_close_matches(arg_name, all_known_options)
if suggestions:
msg += f". Did you mean '{suggestions[0]}'?'"
_LOGGER.warning(msg)
```
--
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]