yacs
yacs copied to clipboard
Evaluation of strings
https://github.com/rbgirshick/yacs/blob/aabe5bd54d193996ceedcff650cff10c38b1f90b/yacs/config.py#L410
This part makes yacs inconsistent with yaml. In yaml if you want a number to be interpreted as a string you can put it in quotes (e.g. 10 vs "10"), but in yacs they will be both converted to numbers.
In which cases is eval used and would it be possible to add an option to disable it?
Hi. I also have the same issue. I am trying to add a phone number but its throwing Type mismatch
error.
sender: "+13342924471" # sender mobile number.
@InnovArul and @Rizhiy, do you guys know any work around until the PR is merged?
No fix yet, please note that #35 will introduce problems with +
, so I don't advise using it.
I see. Thanks for the examples. I didn't think of this scenario. In my case, I just needed to mention the integer as string in YACS config. Not with a "+".
For your scenario, one simple workaround I see is to mention the phone numbers within a tuple.
i.e., sender: ("+13342924471",)
Meanwhile, I have pushed the fix for your scenario (into https://github.com/rbgirshick/yacs/pull/35) that @Rizhiy was suggesting. It seems good so far/passes all tests in yacs/tests.py. I hope it doesn't affect any other functionalities.
@InnovArul thanks for the tuple hack suggestion. Though I have used another hack for the time being:
phone_str = "+{}".format(cfg["phone_num"])
This way I force +
before the string. But I guess the approach can be quite buggy in case someone messes with the config file.