Title: gh-106727: Make `inspect.getsource` smarter for class for same name definitions by gaogaotiantian · Pull Request #106815 · python/cpython · GitHub
Open Graph Title: gh-106727: Make `inspect.getsource` smarter for class for same name definitions by gaogaotiantian · Pull Request #106815 · python/cpython
X Title: gh-106727: Make `inspect.getsource` smarter for class for same name definitions by gaogaotiantian · Pull Request #106815 · python/cpython
Description: When there are multiple class definitions with the same class name found in a file, we currently just return the first one found. This is not the best solution. It would be pretty difficult(maybe not impossible) to do this perfectly. A couple of heuristics are introduced: If a method with a first_lineno is found in the class definition, we think that's our target. If we find the docstring in the definition and only one of the candidates has the match, that's our target. If we can't figure it out, pick the last one. (This is a slightly better guess than the first one). One test case was removed - we happened to be correct on that case, just lucky. We can't solve it right now (flipping the if condition won't make a difference). Issue: gh-106727
Open Graph Description: When there are multiple class definitions with the same class name found in a file, we currently just return the first one found. This is not the best solution. It would be pretty difficult(maybe n...
X Description: When there are multiple class definitions with the same class name found in a file, we currently just return the first one found. This is not the best solution. It would be pretty difficult(maybe n...
Opengraph URL: https://github.com/python/cpython/pull/106815
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cf706f5d-a3c9-4b70-87c9-41c988ebc588 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BFEE:29DE49:1CFDDA8:264465E:6A52D8B8 |
| html-safe-nonce | 7961334e1db23ea1385741e4033edf4fb99d909b5f6a37b1e0ed60917673e792 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkVFOjI5REU0OToxQ0ZEREE4OjI2NDQ2NUU6NkE1MkQ4QjgiLCJ2aXNpdG9yX2lkIjoiNDQ3OTAwMDUzNDY3ODk1MjEyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cf4a5171c76725ac1b574a25be88910558a28c1b42f237438a245dfdf305e446 |
| hovercard-subject-tag | pull_request:1436414352 |
| 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/106815/files |
| twitter:image | https://avatars.githubusercontent.com/u/13121107?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13121107?s=400&v=4 |
| og:image:alt | When there are multiple class definitions with the same class name found in a file, we currently just return the first one found. This is not the best solution. It would be pretty difficult(maybe n... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width