Title: Annotation for getLevelName in logging does not accept `str` but the code does · Issue #1842 · python/typeshed · GitHub
Open Graph Title: Annotation for getLevelName in logging does not accept `str` but the code does · Issue #1842 · python/typeshed
X Title: Annotation for getLevelName in logging does not accept `str` but the code does · Issue #1842 · python/typeshed
Description: Currently for getLevelName in logging there is def getLevelName(lvl: int) -> str: ... However the code for it (Python 3.6.3) accepts a string argument as well: def getLevelName(level): """ Return the textual representation of logging lev...
Open Graph Description: Currently for getLevelName in logging there is def getLevelName(lvl: int) -> str: ... However the code for it (Python 3.6.3) accepts a string argument as well: def getLevelName(level): """ Return t...
X Description: Currently for getLevelName in logging there is def getLevelName(lvl: int) -> str: ... However the code for it (Python 3.6.3) accepts a string argument as well: def getLevelName(level): "&qu...
Opengraph URL: https://github.com/python/typeshed/issues/1842
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Annotation for getLevelName in logging does not accept `str` but the code does","articleBody":"Currently for `getLevelName` in `logging` there is \r\n\r\n```\r\ndef getLevelName(lvl: int) -> str: ...\r\n```\r\n\r\nHowever the code for it (Python 3.6.3) accepts a string argument as well:\r\n```\r\ndef getLevelName(level):\r\n \"\"\"\r\n Return the textual representation of logging level 'level'.\r\n\r\n If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,\r\n INFO, DEBUG) then you get the corresponding string. If you have\r\n associated levels with names using addLevelName then the name you have\r\n associated with 'level' is returned.\r\n\r\n If a numeric value corresponding to one of the defined levels is passed\r\n in, the corresponding string representation is returned.\r\n\r\n Otherwise, the string \"Level %s\" % level is returned.\r\n \"\"\"\r\n # See Issues #22386, #27937 and #29220 for why it's this way\r\n result = _levelToName.get(level)\r\n if result is not None:\r\n return result\r\n result = _nameToLevel.get(level)\r\n if result is not None:\r\n return result\r\n return \"Level %s\" % level\r\n```\r\n\r\nIt is not clear to me from the method's docstring that the behavior of the code with respect to strings is guaranteed, though, so perhaps leaving it as `int` is safer.","author":{"url":"https://github.com/gabbard","@type":"Person","name":"gabbard"},"datePublished":"2018-01-25T22:31:50Z","url":"https://github.com/python/typeshed/issues/1842"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:68549746-f0b4-8b65-ae51-2e664606636d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C20A:157BA1:1DD203:287F38:6B0021F4 |
| html-safe-nonce | bb2ec330e6c6669a36b4a4754f82a266fd76311fa30fea0fdf3eb02326b7b8a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjBBOjE1N0JBMToxREQyMDM6Mjg3RjM4OjZCMDAyMUY0IiwidmlzaXRvcl9pZCI6IjI3NDU5NTMzNjkzMDE0NTk0NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 86d208bd75a96a85949e46b8a3463937a11f92a66aea333c986a8ee778919571 |
| hovercard-subject-tag | issue:291739100 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/1842/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8db0f39d5f398567685b25ca4c0c49467c806940712ee759a07d66c8d2a03510/python/typeshed/issues/1842 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8db0f39d5f398567685b25ca4c0c49467c806940712ee759a07d66c8d2a03510/python/typeshed/issues/1842 |
| og:image:alt | Currently for getLevelName in logging there is def getLevelName(lvl: int) -> str: ... However the code for it (Python 3.6.3) accepts a string argument as well: def getLevelName(level): """ Return t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gabbard |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width