cms-sw / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
1.07k stars 4.29k forks source link

Migrate from optparse to argparse #29338

Open kpedro88 opened 4 years ago

kpedro88 commented 4 years ago

optparse is used frequently in CMSSW, but has been deprecated for quite a while in Python. Migrating to argparse would enable, e.g., enforcing types for input arguments.

I initially noticed this could be improved in runTheMatrix: https://github.com/cms-sw/cmssw/blob/e045dab9e37d05e9572a4d1dce7035aa6414a553/Configuration/PyReleaseValidation/scripts/runTheMatrix.py#L334-L339

but it also applies to many other tools.

kpedro88 commented 4 years ago

assign core,pdmv,upgrade

attn: @davidlange6

cmsbuild commented 4 years ago

New categories assigned: core,upgrade,pdmv

@Dr15Jones,@smuzaffar,@chayanit,@wajidalikhan,@makortel,@pgunnell,@kpedro88 you have been requested to review this Pull request/Issue and eventually sign? Thanks

cmsbuild commented 4 years ago

A new Issue was created by @kpedro88 Kevin Pedro.

@Dr15Jones, @smuzaffar, @silviodonato, @makortel, @davidlange6, @fabiocos can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

srimanob commented 1 year ago

Back to this issue as migration to runTheMatrix happened two year ago. Do you think it is still worth for effort on central migration, @cms-sw/core-l2 ? I think optparse is deprecated since python 3.2. We have many places in cmssw with optparse.

makortel commented 1 year ago

On a quick search it seems that while optparse is deprecated, it is not planned to be removed (mentioned e.g. here https://discuss.python.org/t/formalize-the-concept-of-soft-deprecation-dont-schedule-removal-in-pep-387-backwards-compatibility-policy/27957). So keeping optparse seems unlikely to cause problems in the near future, making this issue being mostly about enhancement, which is then unlikely for such migration to become priority to be done centrally. So there is room for enthusiastic volunteers :)