-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Fix] use hyphen for command line args in demo & tools #808
Conversation
Codecov Report
@@ Coverage Diff @@
## master #808 +/- ##
==========================================
+ Coverage 83.04% 83.10% +0.06%
==========================================
Files 216 217 +1
Lines 12239 12265 +26
Branches 1975 1981 +6
==========================================
+ Hits 10164 10193 +29
+ Misses 1767 1763 -4
- Partials 308 309 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Good job. Maybe markdown files such as |
We can find all
|
I ran
and added code to support previous arguments. |
Would the following implementation be better? We can use only hyphens in We can put this function to The following code is a simple test case, save to import warnings
import sys
import re
def parse_args():
parser = argparse.ArgumentParser(description="Generation demo")
parser.add_argument("--a-b", help="test config file path")
parser.add_argument("--c-d-e", help="test config file path")
parser.add_argument("--f", help="test config file path")
args = parser.parse_args()
return args
def main():
print(sys.argv)
modify_args()
print(sys.argv)
args = parse_args()
print(args)
def modify_args():
for i, v in enumerate(sys.argv):
if i == 0:
assert v.endswith(".py")
elif re.match(r"--\w+_.*", v):
new_arg = v.replace("_", "-")
warnings.warn(
f"command line argument {v} is deprecated, please use {new_arg} instead.",
category=DeprecationWarning,
)
sys.argv[i] = new_arg
if __name__ == "__main__":
main() |
@wangruohui |
@nijkah Thank you very much! |
Should I add a test code for |
Yeah, that will be better. |
* Fix demo args to use hyphen * Update more files and support depracated name * Lint * Add deprecated args util * add pytest for modify_args
* Fix demo args to use hyphen * Update more files and support depracated name * Lint * Add deprecated args util * add pytest for modify_args
closes #804