[fix]:461 fixed with a utility function that checks for booealn inter…#493
[fix]:461 fixed with a utility function that checks for booealn inter…#493thisismeamir wants to merge 7 commits into
Conversation
…pretation fo string and integer content. Raises error to the user otherwise
| return ''.join(random.choices(string.ascii_letters + string.digits, | ||
| k=length)) | ||
|
|
||
| def boolean_of(input, context: str) -> bool : |
There was a problem hiding this comment.
can you also make the function not sensitive to case? For example, "nO" or "trUe" should work as well.
There was a problem hiding this comment.
I was thinking to make the users go to a typesafe region over time that's why I raised the error
| elif input in booleanDictionary["trueStatements"]: | ||
| return True | ||
| else | ||
| raise Exception(f"In ${context} you provided ${input} which cannot be considered a boolean in our source-code please use: False : ${booleanDictionary["falseStatements"]} and True: ${booleanDictionary["trueStatements"]}.") |
There was a problem hiding this comment.
Can you instead of exception issue a warning? using the LOGGER?
|
how's it now? |
| elif statement.lower() in booleanDictionary["trueStatements"]: | ||
| return True | ||
| else: | ||
| LOGGER.warning(f"In ${context} you provided ${input} which cannot be considered a boolean in our source-code please use: False : ${booleanDictionary["falseStatements"]} and True: ${booleanDictionary["trueStatements"]}.") |
There was a problem hiding this comment.
You need to escape the double quotes ". or use single quotes '.
There was a problem hiding this comment.
Nice, can you remove in our source-code from the warning message?
| LOGGER: logging.Logger | ||
|
|
||
| def generate_graph(dframe, args, suffix: str | None = None) -> None: ... | ||
| def boolean_of(): ... |
|
To get on board again. I have a function And I've also used it in |
The #461 opened the possibility that the user might un-intentionally enter string values instead of boolean for some inputs, resulting in an always
Truecase.I've added a utility function after the discussion with @kjvbrt about it and fixed the related histogram logarithmic scale bug with it as well.