-
Notifications
You must be signed in to change notification settings - Fork 195
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
fix: replace strtobool for local function #128
fix: replace strtobool for local function #128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liked the tests. With minor improvements I can merge it.
tests/test_util.py
Outdated
def test_invalid_value_text(): | ||
invalid_list = ["Invalid_Value_1", "1nv4l1d_V4lu3_2", "Invalid_Value_3"] | ||
for value in invalid_list: | ||
with pytest.raises(ValueError, match="invalid truth value '%s'".format(value)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don't like this single test with a loop.
- The error string should be a constant without
format
.
Please check pytest's parametrize
tests/test_util.py
Outdated
@@ -0,0 +1,21 @@ | |||
import pytest | |||
from util import strtobool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils
is a symptom of lack of a proper abstraction. Please, do not use it. Keep the strtobool
function on the main file decouple.py
since it's not used anywhere else.
util.py
Outdated
@@ -0,0 +1,9 @@ | |||
def strtobool(value): | |||
value = value.lower() | |||
if value in ["y", "yes", "t", "true", "on", "1"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comparisons are O(N) and always recreate the list. Make the list definition global and use a set instead of a list.
Issue
The distutils module was deprecated in PEP 632.
resolve #127
Solution
Creation of a local function to replace the strtobool function used by distutils.