You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Brad Schoening (Jira)" <ji...@apache.org> on 2023/06/27 18:39:00 UTC

[jira] [Comment Edited] (CASSANDRA-17914) Argparse migration as the Python Optparse library is deprecated

    [ https://issues.apache.org/jira/browse/CASSANDRA-17914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17737828#comment-17737828 ] 

Brad Schoening edited comment on CASSANDRA-17914 at 6/27/23 6:38 PM:
---------------------------------------------------------------------

[~stefan.miklosovic] would you be able to review this PR?

 

Note: I did ask the mailing list back on Sept 29 2022 and there were no objections to changing from the deprecated library here to argparse.


was (Author: bschoeni):
[~stefan.miklosovic] would you be able to review this PR?

> Argparse migration as the Python Optparse library is deprecated
> ---------------------------------------------------------------
>
>                 Key: CASSANDRA-17914
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17914
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL/Interpreter
>            Reporter: Brad Schoening
>            Assignee: Vineet Gali
>            Priority: Normal
>
> [Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.|https://docs.python.org/2/library/optparse.html]
> Argparse is described in [PEP 389 – argparse - New Command Line Parsing Module|https://peps.python.org/pep-0389/]
>  
> A partial upgrade path from [{{optparse}}|https://docs.python.org/3/library/optparse.html#module-optparse] to [{{argparse}}|https://docs.python.org/3/library/argparse.html#module-argparse]:
> https://docs.python.org/3/library/argparse.html#upgrading-optparse-code
>  * Replace all [{{optparse.OptionParser.add_option()}}|https://docs.python.org/3/library/optparse.html#optparse.OptionParser.add_option] calls with [{{ArgumentParser.add_argument()}}|https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument] calls.
>  * Replace {{(options, args) = parser.parse_args()}} with {{args = parser.parse_args()}} and add additional [{{ArgumentParser.add_argument()}}|https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument] calls for the positional arguments. Keep in mind that what was previously called {{{}options{}}}, now in the [{{argparse}}|https://docs.python.org/3/library/argparse.html#module-argparse] context is called {{{}args{}}}.
>  * Replace [{{optparse.OptionParser.disable_interspersed_args()}}|https://docs.python.org/3/library/optparse.html#optparse.OptionParser.disable_interspersed_args] by using [{{parse_intermixed_args()}}|https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_intermixed_args] instead of [{{parse_args()}}|https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_args].
>  * Replace callback actions and the {{callback_*}} keyword arguments with {{type}} or {{action}} arguments.
>  * Replace string names for {{type}} keyword arguments with the corresponding type objects (e.g. int, float, complex, etc).
>  * Replace {{optparse.Values}} with [{{Namespace}}|https://docs.python.org/3/library/argparse.html#argparse.Namespace] and {{optparse.OptionError}} and {{optparse.OptionValueError}} with {{{}ArgumentError{}}}.
>  * Replace strings with implicit arguments such as {{%default}} or {{%prog}} with the standard Python syntax to use dictionaries to format strings, that is, {{%(default)s}} and {{{}%(prog)s{}}}.
>  * Replace the OptionParser constructor {{version}} argument with a call to {{{}parser.add_argument('--version', action='version', version='<the version>'){}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org