Skip to content
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 `logging.getLevelName()` type hints #2730

Merged
merged 1 commit into from Jan 17, 2019

Conversation

Projects
None yet
3 participants
@noseworthy
Copy link
Contributor

commented Jan 9, 2019

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.

@sproshev

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2019

Seems that it's better to change return type to Any. See conventions and python/mypy#1693

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.

@noseworthy noseworthy force-pushed the noseworthy:fix_logging_get_level_name_stub branch from c91a28b to 430155b Jan 9, 2019

@noseworthy

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2019

@sproshev: My bad. Missed that in the contribution guidelines. Should be fixed now!

@srittau
Copy link
Collaborator

left a comment

Thank you!

@srittau srittau merged commit e8c1111 into python:master Jan 17, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@noseworthy noseworthy deleted the noseworthy:fix_logging_get_level_name_stub branch Jan 17, 2019

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019

Fix `logging.getLevelName()` type hints (python#2730)
`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.