Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation of strings #26

Open
Rizhiy opened this issue Jul 23, 2019 · 4 comments
Open

Evaluation of strings #26

Rizhiy opened this issue Jul 23, 2019 · 4 comments

Comments

@Rizhiy
Copy link
Contributor

Rizhiy commented Jul 23, 2019

value = literal_eval(value)

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?

@Rizhiy Rizhiy changed the title Evaluation is strings Evaluation of strings Jul 23, 2019
@muzammil360
Copy link

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?

@Rizhiy
Copy link
Contributor Author

Rizhiy commented Jan 1, 2020

No fix yet, please note that #35 will introduce problems with +, so I don't advise using it.

@InnovArul
Copy link

InnovArul commented Jan 1, 2020

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 #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.

@muzammil360
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants