-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix logging.getLevelName()
type hints
#2730
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
Merged
srittau
merged 1 commit into
python:master
from
noseworthy:fix_logging_get_level_name_stub
Jan 17, 2019
Merged
Fix logging.getLevelName()
type hints
#2730
srittau
merged 1 commit into
python:master
from
noseworthy:fix_logging_get_level_name_stub
Jan 17, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Seems that it's better to change return type to |
`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: My bad. Missed that in the contribution guidelines. Should be fixed now! |
srittau
approved these changes
Jan 17, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
yedpodtrzitko
pushed a commit
to yedpodtrzitko/typeshed
that referenced
this pull request
Jan 23, 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.
cjwatson
added a commit
to cjwatson/typeshed
that referenced
this pull request
Jun 3, 2024
To better reflect the implementation's behaviour, python#2730 changed `logging.getLevelName` to accept `int | str` and return `Any` (the latter due to the need to avoid union return types). However, this isn't ideal if you're passing in an `int`, in which case the implementation always returns a `str`. Add overloads for this. This is all arguably a bit unfortunate in light of python#1842 (comment), but I don't want to relitigate that here. I've at least left a comment.
srittau
pushed a commit
that referenced
this pull request
Jun 4, 2024
To better reflect the implementation's behaviour, #2730 changed `logging.getLevelName` to accept `int | str` and return `Any` (the latter due to the need to avoid union return types). However, this isn't ideal if you're passing in an `int`, in which case the implementation always returns a `str`. Add overloads for this.
max-muoto
pushed a commit
to max-muoto/typeshed
that referenced
this pull request
Sep 8, 2024
To better reflect the implementation's behaviour, python#2730 changed `logging.getLevelName` to accept `int | str` and return `Any` (the latter due to the need to avoid union return types). However, this isn't ideal if you're passing in an `int`, in which case the implementation always returns a `str`. Add overloads for this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
logging.getLevelName()
can take either anint
and returns astr
ora
str
and returns anint
when the level name (str
) or level(
int
) is one of the registered log levels. If the value passed inisn't one of the registered log levels, it returns the string
"level %s" % lvl
wherelvl
is the value passed in to the function.Updated the type hints to better reflect this functionality.