Title: bpo-33211: Add def_lineno and class_lineno attributes to FunctionDef and ClassDef by emmatyping · Pull Request #6410 · python/cpython · GitHub
Open Graph Title: bpo-33211: Add def_lineno and class_lineno attributes to FunctionDef and ClassDef by emmatyping · Pull Request #6410 · python/cpython
X Title: bpo-33211: Add def_lineno and class_lineno attributes to FunctionDef and ClassDef by emmatyping · Pull Request #6410 · python/cpython
Description: As reported in the bug, a decorated function or class like below will report the first line of the decorator as its line number (so the FunctionDef.lineno will be 1). @decorate( "multi", "line" ) def foo( a, b, ): pass This change adds a def_lineno for functions and class_lineno for classes. These attributes report the real line numbers of the beginning of the function or class definition. This is especially valuable for linters and tools parsing Python. I wasn't sure where to put something in the docs since the ast docs are sparse. This isn't quite ready yet, I need to figure out what changes I need to make to the unparser (which I will do tomorrow). https://bugs.python.org/issue33211
Open Graph Description: As reported in the bug, a decorated function or class like below will report the first line of the decorator as its line number (so the FunctionDef.lineno will be 1). @decorate( "multi...
X Description: As reported in the bug, a decorated function or class like below will report the first line of the decorator as its line number (so the FunctionDef.lineno will be 1). @decorate( "m...
Opengraph URL: https://github.com/python/cpython/pull/6410
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4e6f7a57-310a-ce0f-da50-f884f2ccf2c8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D2E4:52373:C1B6E5:107B540:6A55B3D3 |
| html-safe-nonce | ab49d4fefc91271a00e539861fb9f9625571105bd5a14fb3ea6190f3990c24d4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMkU0OjUyMzczOkMxQjZFNToxMDdCNTQwOjZBNTVCM0QzIiwidmlzaXRvcl9pZCI6IjY1MjEwMDcxODYxMTgwMzAyOTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9c58f42510fa10161e3014f0b0c48184a03379fd1423401fefd689a3eb90b1f5 |
| hovercard-subject-tag | pull_request:180103054 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/6410/files |
| twitter:image | https://avatars.githubusercontent.com/u/9504279?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/9504279?s=400&v=4 |
| og:image:alt | As reported in the bug, a decorated function or class like below will report the first line of the decorator as its line number (so the FunctionDef.lineno will be 1). @decorate( "multi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653fccf1e27344851c0d3de3fa6faa526197f072 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width