From 430155bdccd1395e2d09fe9d3a651ef0f444f295 Mon Sep 17 00:00:00 2001 From: Mike Noseworthy Date: Wed, 9 Jan 2019 12:07:46 -0330 Subject: [PATCH] Fix `logging.getLevelName()` type hints `logging.getLevelName()` can take either an `int` and returns a `str` or a `str` and returns an `int` when the level name (`str`) or level (`int`) is one of the registered log levels. If the value passed in isn't one of the registered log levels, it returns the string `"level %s" % lvl` where `lvl` is the value passed in to the function. Updated the type hints to better reflect this functionality. --- stdlib/2and3/logging/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/logging/__init__.pyi b/stdlib/2and3/logging/__init__.pyi index 5fe9e19cc977..dbbe200fb130 100644 --- a/stdlib/2and3/logging/__init__.pyi +++ b/stdlib/2and3/logging/__init__.pyi @@ -348,7 +348,7 @@ fatal = critical def disable(lvl: int) -> None: ... def addLevelName(lvl: int, levelName: str) -> None: ... -def getLevelName(lvl: int) -> str: ... +def getLevelName(lvl: Union[int, str]) -> Any: ... def makeLogRecord(attrdict: Mapping[str, Any]) -> LogRecord: ...