Skip to content

add _levelNames to logging/__init__.py#1404

Merged
JelleZijlstra merged 2 commits intomasterfrom
logging
Jun 13, 2017
Merged

add _levelNames to logging/__init__.py#1404
JelleZijlstra merged 2 commits intomasterfrom
logging

Conversation

@matthiaskramm
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread stdlib/2and3/logging/__init__.pyi Outdated

raiseExceptions: bool

_levelNames = ... # type: Dict[int, str]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python 3.6, this doesn't exist; instead there is _levelToName. In Python 2.7 it does exist under this name, but it has both the int/str mapping and the reverse str/int mapping. I haven't checked earlier versions of Python 3, but do we really need this private name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@matthiaskramm
Copy link
Copy Markdown
Contributor Author

I made _levelNames on Python 2 a plain dict (not: a Dict[Union[int, str], Union[int, str]]), because I'm worried about false positives when type-checking code like this:

logging._levelNames["DEBUG"] + 1

@JelleZijlstra JelleZijlstra merged commit 6849262 into master Jun 13, 2017
@JelleZijlstra JelleZijlstra deleted the logging branch June 13, 2017 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants