Title: gh-145413: Fix nested attribute suggestions executing property code by Hiumee · Pull Request #145414 · python/cpython · GitHub
Open Graph Title: gh-145413: Fix nested attribute suggestions executing property code by Hiumee · Pull Request #145414 · python/cpython
X Title: gh-145413: Fix nested attribute suggestions executing property code by Hiumee · Pull Request #145414 · python/cpython
Description: Updated the code of _check_for_nested_attribute to check properties without triggering their code. This approach will still suggest them
Changed a test case to look for side effects and changed some contradictory comments
Updated the news section code to include imports so the code can be tested out of the box
Example
from dataclasses import dataclass
from math import pi
@dataclass
class Circle:
radius: float
@property
def area(self) -> float:
print("Property 'area' accessed")
return pi * self.radius**2
class Container:
def __init__(self, inner: Circle) -> None:
self.inner = inner
circle = Circle(radius=4.0)
container = Container(circle)
print(container.area)
Output
Traceback (most recent call last):
File "
Open Graph Description: Updated the code of _check_for_nested_attribute to check properties without triggering their code. This approach will still suggest them Changed a test case to look for side effects and changed som...
X Description: Updated the code of _check_for_nested_attribute to check properties without triggering their code. This approach will still suggest them Changed a test case to look for side effects and changed som...
Opengraph URL: https://github.com/python/cpython/pull/145414
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:96481261-2ff1-c627-9978-b9e75da3869b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E2C6:1EDC:6346B86:8AFAAC0:6A50ED8E |
| html-safe-nonce | 0598707a5846859f0a1a6b305d992f7b890cb23c8766b2b19446caeec8aaf22f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkM2OjFFREM6NjM0NkI4Njo4QUZBQUMwOjZBNTBFRDhFIiwidmlzaXRvcl9pZCI6IjUzMDE2MzE1NTA5MTU0MDcyNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f7ff6b9a90fdd3ff274d4115aa0e5acf2ec2394b1439620efc22d3f26193ea69 |
| hovercard-subject-tag | pull_request:3343834523 |
| 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/145414/files |
| twitter:image | https://avatars.githubusercontent.com/u/42638867?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/42638867?s=400&v=4 |
| og:image:alt | Updated the code of _check_for_nested_attribute to check properties without triggering their code. This approach will still suggest them Changed a test case to look for side effects and changed som... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| 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 | 5ec60191a48933536a90c8a19f47142fcd0d4739 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width