Change strtobool to ignore the to-bool conversion when the input value is a bool
This pull-request prevents an error from being thrown if the default value is used and it is a bool instead of a string.
Quick way to reproduce the error:
from decouple import config, strtobool
DEBUG = config('DEBUG', default=False, cast=strtobool)
DEBUG = config('DEBUG', default=False, cast=strtobool)
File "/home/luzfcb/.virtualenvs/myenv/lib/python3.9/site-packages/decouple.py", line 197, in __call__
return self.config(*args, **kwargs)
File "/home/luzfcb/.virtualenvs/myenv/lib/python3.9/site-packages/decouple.py", line 85, in __call__
return self.get(*args, **kwargs)
File "/home/luzfcb/.virtualenvs/myenv/lib/python3.9/site-packages/decouple.py", line 79, in get
return cast(value)
File "/home/luzfcb/.virtualenvs/myenv/lib/python3.9/site-packages/decouple.py, line 36, in strtobool
value = value.lower()
AttributeError: 'bool' object has no attribute 'lower'
Process finished with exit code 1
Change
strtobool
to ignore the to-bool conversion when the input value is a boolThis pull-request prevents an error from being thrown if the default value is used and it is a
bool
instead of astring
.Quick way to reproduce the error: