-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Hello there,
First of all: thanks a lot for the great library. It has sensibly improved our life when writing custom resources.
I have found a small inconsistency in the type hints for the CfnResource's log_level constructor parameter.
Current behavior
Version affected: main branch f2095c5
CfnResource constructor specifies that log_level should be a string.
In practice though, the log_level is used in log_helper.py to set the log level on the root logger in the stdlib logging module.
logging.root.setLevel(level)The logging module supports both string and integers to specify the log level. As a matter of fact, the log level is stored internally as an integer. The string is translated to an int using the _checkLevel method:
def _checkLevel(level):
if isinstance(level, int):
rv = level
elif str(level) == level:
if level not in _nameToLevel:
raise ValueError("Unknown level: %r" % level)
rv = _nameToLevel[level]
else:
raise TypeError("Level not an integer or a valid string: %r" % level)
return rvExpected behavior
log_level type hint should support both string and int.
Contribution
I am more than happy to create a PR to fix this, provided that you think it should be fixed.